Embedding Models
llmware supports 30+ embedding models out of the box in the default ModelCatalog, with easy extensibility to add other popular open source embedding models from HuggingFace or Sentence Transformers.
To get a list of the currently supported embedding models:
from llmware.models import ModelCatalog
embedding_models = ModelCatalog().list_embedding_models()
for i, models in enumerate(embedding_models):
print(f"embedding models: {i} - {models}")
Supported popular models include:
- Sentence Transformers -
all-MiniLM-L6-v2
,all-mpnet-base-v2
- Jina AI -
jinaai/jina-embeddings-v2-base-en
,jinaai/jina-embeddings-v2-small-en
- Nomic -
nomic-ai/nomic-embed-text-v1
- Industry BERT -
industry-bert-insurance
,industry-bert-contracts
,industry-bert-asset-management
,industry-bert-sec
,industry-bert-loans
- OpenAI -
text-embedding-ada-002
,text-embedding-3-small
,text-embedding-3-large
We also support top embedding models from BAAI, thenlper, llmrails/ember, Google, and Cohere. We are constantly looking to add new innovative open source models to this list so please let us know if you are looking for support for a specific embedding model, and usually within 1-2 days, we can test and add to the ModelCatalog.
Using an Embedding Model
Embedding models in llmware can be installed directly by ModelCatalog().load_model("model_name")
, but in most cases, the name of the embedding model will be passed to the install_new_embedding
handler in the Library class when creating a new embedding. Once that is completed, the embedding model is captured in the Library metadata on the LibraryCard as part of the embedding record for that library, and as a result, often times, does not need to be used explicitly again, e.g.,
from llmware.library import Library
library = Library().create_new_library("my_library")
# parses the content from the documents in the file path, text chunks and indexes in a text collection database
library.add_files(input_folder_path="/local/path/to/my_files", chunk_size=400, max_chunk_size=600, smart_chunking=1)
# creates embeddings - and keeps synchronized records of which text chunks have been embedded to enable incremental use
library.install_new_embedding(embedding_model_name="jinaai/jina-embeddings-v2-small-en",
vector_db="milvus",
batch_size=100)
Once the embeddings are installed on the library, you can look up the embedding status to see the updated embeddings, and confirm that the model has been correctly captured:
from llmware.library import Library
library = Library().load_library("my_library")
embedding_record = library.get_embedding_status()
print("\nupdate: embedding record - ", embedding_record)
And then you can run semantic retrievals on the Library, using the Query class in the retrievals module, e.g.:
from llmware.library import Library
from llmware.retrieval import Query
library = Library().load_library("my_library")
# queries are constructed by creating a Query object, and passing a library as input
query_results = Query(library).semantic_query("my query", result_count=20)
for qr in query_results:
print("my query results: ", qr)
Need help or have questions?
Check out the llmware videos and GitHub repository.
Reach out to us on GitHub Discussions.
About the project
llmware
is © 2023-2024 by AI Bloks.
Contributing
Please first discuss any change you want to make publicly, for example on GitHub via raising an issue or starting a new discussion. You can also write an email or start a discussion on our Discord channel. Read more about becoming a contributor in the GitHub repo.
Code of conduct
We welcome everyone into the llmware
community. View our Code of Conduct in our GitHub repository.
llmware
and AI Bloks
llmware
is an open source project from AI Bloks - the company behind llmware
. The company offers a Software as a Service (SaaS) Retrieval Augmented Generation (RAG) service. AI Bloks was founded by Namee Oberst and Darren Oberst in October 2022.
License
llmware
is distributed by an Apache-2.0 license.