Skip to content

Commit

Permalink
Add the llama index examples
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Apr 15, 2024
1 parent a2a1bd6 commit 1c44606
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/llama_index/mistral_gguf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.core.embeddings import resolve_embed_model
from llama_index.llms.mistral_rs import MistralRS

documents = SimpleDirectoryReader("data").load_data()

# bge embedding model
Settings.embed_model = resolve_embed_model("local:BAAI/bge-small-en-v1.5")

# ollama
Settings.llm = MistralRS(
model_id="mistralai/Mistral-7B-Instruct-v0.1",
arch="mistral-gguf",
quantized_model_id="TheBloke/Mistral-7B-Instruct-v0.1-GGUF",
quantized_filename="mistral-7b-instruct-v0.1.Q4_0.gguf",
max_new_tokens=4096,
context_window=1000,
)

index = VectorStoreIndex.from_documents(
documents,
)

query_engine = index.as_query_engine()
response = query_engine.query("Please summarize the above.")
print(response)
26 changes: 26 additions & 0 deletions examples/llama_index/xlora_gguf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.core.embeddings import resolve_embed_model
from llama_index.llms.mistral_rs import MistralRS

documents = SimpleDirectoryReader("data").load_data()

# bge embedding model
Settings.embed_model = resolve_embed_model("local:BAAI/bge-small-en-v1.5")

# ollama
Settings.llm = MistralRS(
model_id="HuggingFaceH4/zephyr-7b-beta",
arch="x-lora-mistral",
xlora_order_file="ordering.json", # Copy your ordering file to where this file will be run from
xlora_model_id="lamm-mit/x-lora",
max_new_tokens=4096,
context_window=1000,
)

index = VectorStoreIndex.from_documents(
documents,
)

query_engine = index.as_query_engine()
response = query_engine.query("Please summarize the above.")
print(response)

0 comments on commit 1c44606

Please sign in to comment.