API access solution - 3rd party model. | On-premise solution - open source model. | |
---|---|---|
R&D developpement | The low initial cost, both in terms of time and money, allows us to quickly reach a Minimum Viable Product (MVP). The procedure for model parameter optimization and MLops is overseen by a third-party e |
Provider | Model | Cost for input | Cost for output | Cost per request. |
---|---|---|---|---|
OpenAI | text-davinci-004 | $0.03/ 1K tokens | $0.06/ 1K tokens | 0 |
OpenAI | text-davinci-003 | $0.02/ 1K tokens | $0.02/ 1K tokens | 0 |
OpenAI | text-davinci-002 | $0.002/ 1K tokens | $0.002/ 1K tokens | 0 |
OpenAI | gpt-3.5-turbo | $0.002/ 1K tokens | $0.002/ 1K tokens | 0 |
[Cohere](https://cohere.com/pri |
Provider | Model | Number of parameters |
---|---|---|
Meta with Microsoft | LLama 2 | 7B, 13B, 32B, 65.2B |
Meta | LLama | 7B, 13B, 70B |
Technology Innovation Institute of UAE | Flacon LLM | 7B, 40B |
Stanford’s CRFM | Alpaca | 7B |
Plan-T5 | 80M, 250M, 780M, 3B, 11B | |
MPT | MosaicML | 7B, 30B |
Direct query Information appearing in text (entity extraction, summarization, find relevant paragraphs, etc … ). |
Indirect query Inferenced information (mathematical calculation, comparison, conclusion, etc …). |
|
---|---|---|
Simple text Text containing descriptions excluding table. |
Complexity: + Accuracy: +++ |
Complexity: ++ Accuracy: +++ |
Complex textText |
This file contains hidden or 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
pinecone.init(api_key="YOUR_API_KEY", environment="YOUR_ENVIRONMENT") | |
index = pinecone.Index("projet_esg") |
This file contains hidden or 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
index.describe_index_stats() |
This file contains hidden or 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
values = embedd_model.encode([b['content'] for b in batch]) | |
sparse_values = sparsed_model.encode([b['content'] for b in batch]) | |
# Create unique IDs | |
ids = [str(b['metadata']['id']) for b in batch] | |
# Add all to upsert list | |
to_upsert = [{'id': i, 'values': v, 'metadata':m , 'sparse_values': sv} for (i,v,m,sv) in zip(ids,values, metas, sparse_values)] | |
# Upsert/insert these records to pinecone |
This file contains hidden or 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
index.describe_index_stats() | |
# Return for example: | |
{ | |
'dimension': 1536, | |
'index_fullness': 0.1, | |
'namespaces': { | |
'Eiffage': {'vector_count': 344}, | |
'total_vector_count': 344 | |
} |
This file contains hidden or 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
from openai import Embedding | |
from pinecone_text.sparse import BM25Encoder | |
EMBEDDING_MODEL = "text-embedding-ada-002" | |
SPARSE_MODEL_FILE_NAME = "bm25_values.json" | |
class Embedding_Model(Embedding): | |
def __init__(self, model_name): | |
self.engine = model_name |
This file contains hidden or 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
from pinecone import Index | |
class Retreiver(Index): | |
def __init__(self, index_name, embedd_openai_model, sparse_model_file_name, dimension=1536, metric="dotproduct"): | |
self.index_name = index_name | |
# Create index | |
if index_name not in pinecone.list_indexes(): |