This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the API Key, either by setting the env var or editing it directly here: | |
openai_api_key = [YOUR_OPENAI_KEY] | |
# Create a new prompter using any desired model (GPT-3.5)and add the query_results | |
prompt_text = "Summarize the criticality provisions" | |
print (f"\n > Prompting LLM with '{prompt_text}'") | |
prompter = Prompt().load_model("gpt-3.5-turbo", api_key=openai_api_key) | |
sources = prompter.add_source_query_results(query_res) | |
# Prompt the LLM with the sources and query string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
embedded_text = '' | |
for q in query_res: | |
embedded_text += '\n'.join(q['text'].split("\'\'")) | |
# check all of the pertinent HuggingFace models for performance | |
models = ["llmware/bling-1b-0.1", | |
"llmware/bling-1.4b-0.1", | |
"llmware/bling-falcon-1b-0.1", | |
"llmware/bling-cerebras-1.3b-0.1", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Construct the query | |
query = 'What is defined as criticality?' | |
query_res = Query(library).semantic_query(query, result_count=2) | |
print(query_res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create vector embeddings for the library and store them in Milvus | |
# Opt for the industry-bert-asset-management model which is trained for our domain | |
library.install_new_embedding(embedding_model_name="industry-bert-asset-management", vector_db="milvus") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a library and load it with llmware samples | |
library = Library().create_new_library("Project_lib") | |
library.add_files([REPLACE_WITH_DOCS_PATH]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a test library and load it with llmware samples | |
test_library = Library().create_new_library("Agreements") | |
samples_path = Setup().load_sample_files() | |
test_library.add_files(os.path.join(samples_path,"Agreements")) | |
# Create vector embeddings for the library and store them in Milvus | |
test_library.install_new_embedding(embedding_model_name="industry-bert-contracts", vector_db="milvus") | |
# Perform a semantic search in the test library | |
os.environ["TOKENIZERS_PARALLELISM"] = "false" # HuggingFace tokenizer warning to be avoided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import dependencies | |
import os | |
import time | |
from llmware.library import Library | |
from llmware.retrieval import Query | |
from llmware.prompts import Prompt | |
from llmware.setup import Setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -o docker-compose.yaml https://raw.githubusercontent.com/llmware-ai/llmware/main/docker-compose.yaml | |
docker compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install transformers | |
pip install transformers | |
# Install llmware | |
pip install llmware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature | TensorFlow | PyTorch | Scikit-Learn | |
---|---|---|---|---|
Ease of Use | Moderate complexity and extensive documentation | Pythonic and intuitive | Beginner-friendly & straightforward | |
Flexibility | High supports both high & low-level APIs | Dynamic computation graph | Focused on simplicity & less flexible | |
Community Support | Extensive and large community | Strong community especially in research | Well-established supportive community | |
Use Case Versatility | Broad range of machine learning tasks | Research and dynamic networks | Classic machine learning tasks |
NewerOlder