license: other
license_name: open-aleph-license
license_link: LICENSE
Model Card for Pharia-1-Embedding-4608-control
This model card provides an overview of Pharia-1-Embedding-4608-control, an embedding model developed by Aleph Alpha Research*. Pharia-1-Embedding-4608-control has been built on top of Pharia-1-LLM-7B-control. For additional training details, including architecture, tokenization, tokenizer fertility, pre-training, instruction fine-tuning and resource usage we refer to the model card of Pharia-1-LLM-7B-control. Due to being trained with a diverse set of instructions, Pharia-1-Embedding-4608-control can deliver customized embeddings at runtime without further finetuning. Pharia-1-Embedding-4608-control was trained on carefully curated data in compliance with applicable EU and national regulations, including copyright and data privacy laws. Furthermore it shows good cross-lingual performance allowing for prompting and text to be embedded written in different languages. The finetuning was always performed using English instructions.
Model Overview
- Developed by: Aleph Alpha Research
- Model type: Embedding adapter on top of Pharia-1-LLM-7B-control trained with representational instruction-tuning (inspired by the approach of GritLM).
- Language(s) (NLP): Trained on English, German, French, Spanish.
Model Description
Model | Embedding Size | Description |
---|---|---|
Pharia-1-Embedding-4608-control | 4608 | Pharia-1-Embedding-4608-control is an Embedding model optimized for German, French and Spanish and designed for customizable embeddings at runtime via instructions (prompts) |
Model Access
We provide access to our models through the channels listed below.
- On-premise installation: Our customers are supplied with our full LLM and Embedding model stack, including model weights and inference runtime. Contact us for options to deploy Pharia-1-Embedding-4608-control in any cloud or on-premise environment. We provide our customers with open access to our full model checkpoint including weights and code for commercial use. Please refer to the changelog for updates to the models served. We do not deprecate officially released versions of old model generations when we release newer versions, so users can continue to have access to available models. No prompt data is stored when using our systems, which means that we do not collect PII (personally identifiable information) for any of our public API users as detailed in our Terms & Conditions. We do not log user inputs to the models. We do not train on user data.
- Note: The same models are made available to users regardless of their geographic location, and the input language but subject to sanction regimes, technology export regulations, and other restrictions that may apply. The same offering is provided to all countries within and external to the European Union if no legal restrictions apply.
Intended Use
Pharia-1-Embedding-4608-control is intended to be deployed as components of AI systems or applications. Use-cases and the model's capabilities include but are not limited to: information retrieval, semantic search, re-ranking and clustering.
Out-of-Scope Use
Pharia-1-Embedding-4608-control is not to be used for illegal or unlawful actions of any kind and with any illegal or unlawful content. This includes in particular prohibited activities such as engaging in terrorism, violence, human trafficking, illegal distribution of materials to minors, sexual solicitation, any other criminal activities, harassment, discrimination, creating or promoting malicious code or activities risking death or harm, including those related to military or nuclear applications, and activities not in compliance with sanction regimes, technology export regulations, and other restrictions that may apply. The models are to be used following ethical standards. The utilization of our technology is always governed by, and may be limited in accordance with, our Terms of Use, the Open Aleph License, or any specific agreement we might have established with you. For non-anonymous reports, we also provide an appeals mechanism for usage policy violations via our dedicated contact address [email protected] to communicate with us.
Customers and partners are enabled to use our ticketing system ticketing system for appeals, claims and feedback.
Use limitations
Beyond the risks & limitations stated in the original Pharia-1-LLM-7B-control, the following limitation applies: Pharia-1-Embedding-4608-control has been optimized on embedding computation only. Therefore, we do not recommend usage for text generation purposes.
How to Use
Use with scaling inference code base
To perform inference with the original model files, you’ll first need to install the Scaling library. Follow the installation instructions provided in the repository's README file. After installation, download the model weights and use the Scaling inference module to load the checkpoint, vocabulary, and configuration files.
from pathlib import Path
from torch.nn import CosineSimilarity
from scaling.transformer.inference import TransformerInferenceModule
MODEL_PATH = "/path/to/model"
inference_model = TransformerInferenceModule.from_checkpoint(
checkpoint_dir=Path(MODEL_PATH),
)
# embed the query:
query = "Which country is Galileo from?"
query_embeddings = inference_model.encode_queries(query, convert_to_tensor=True)
print(f"Type of embeddings: {type(query_embeddings)},\n\
shape of query embeddings: {query_embeddings.shape}")
# embed the documents:
document_1 = "Galileo is a German television program series produced and broadcast on ProSieben television network. It is also sold to broadcasters in other countries (namely Russia and Poland). The first show was broadcast in 1998, and is now stored in the Arctic World Archive in Svalbard, Norway, after being transferred to special film created by Piql."
document_embeddings_1 = inference_model.encode_corpus(document_1, convert_to_tensor=True)
document_2 = "Galileo di Vincenzo Bonaiuti de' Galilei (15 February 1564 - 8 January 1642), commonly referred to as Galileo Galilei or mononymously as Galileo, was an Italian (Florentine) astronomer, physicist and engineer, sometimes described as a polymath. He was born in the city of Pisa, then part of the Duchy of Florence and present-day Italy."
document_embeddings_2 = inference_model.encode_corpus(document_2, convert_to_tensor=True)
# customized embeddings steering the query:
instruction = "Represent the question about TV shows to find a paragraph that answers it."
steered_query_embeddings = inference_model.encode_queries(query,
instruction=instruction,
convert_to_tensor=True)
# compute similarity between steered query and both documents
cossim = CosineSimilarity(dim=1, eps=1e-6)
sim1 = round(cossim(document_embeddings_1, steered_query_embeddings).item(), 3)
sim2 = round(cossim(document_embeddings_2, steered_query_embeddings).item(), 3)
print("Steered embedding causes higher similarity of query to TV show:")
print(f"Similarity query/TV show ({sim1}) > similarity query/Italian polymath: ({sim2})")
Explanation of the instruct embedding code example
Pharia-1-Embedding-4608-control is useful for any use-case that relates to estimating the similarity/relevance between text fragments. This is relevant for use-cases such as information retrieval, semantic search, re-ranking and clustering. We use the task of information retrieval as a guiding example where we assume the following query: “Which country is Galileo from?” and two documents:
- Galileo is a German television program series produced and broadcast on ProSieben television network. It is also sold to broadcasters in other countries (namely Russia and Poland). The first show was broadcast in 1998, and is now stored in the Arctic World Archive in Svalbard, Norway, after being transferred to special film created by Piql.
- Galileo di Vincenzo Bonaiuti de' Galilei (15 February 1564 - 8 January 1642), commonly referred to as Galileo Galilei or mononymously as Galileo, was an Italian (Florentine) astronomer, physicist and engineer, sometimes described as a polymath. He was born in the city of Pisa, then part of the Duchy of Florence and present-day Italy. Source: Wikipedia For our guiding example we assume the context of this use-case is a Question-Answer system for movies and TV shows.
Step 1:
Embed the Query
"input": "Which country is Galileo from?"
→ Embedding: [-0.6780134, 0.61449033, 0.102911085, ...]
Step 2:
Embed the Documents
"input": "Galileo is a German television program series ..."
→ Embedding: [-0.36119246, 0.7793595, -0.38735497, ...]
"input": "Galileo di Vincenzo Bonaiuti de' Galilei ..."
→ Embedding: [-0.25108248, 1.0496024, -0.20945309, ...]
Step 3:
Compare the similarity A typical similarity measure between vectors is cosine similarity. Higher numbers indicate more similar vectors and by extension capture the concept of relevance. In a RAG application these scores determine the ranking during the retrieval step. In this example, we obtain the following cosine similarities: Query vs. German TV show: ~0.661 Query vs. Italian polymath: ~0.757 This implies that the paragraph about the Italian polymath would be ranked higher than the paragraph about the German TV show which is the one we’re interested in.
Customized Embeddings
To further improve performance you can use instructions to steer the model. Instructions can help the model
understand nuances of your specific data and ultimately lead to embeddings that are more useful for your use-case.
In this case, we aim to get embeddings that would lead to ranking the paragraph about the German TV Show higher
than the paragraph about the Italian polymath.
Step 1:
Embed the Query with an Instruction
"instruction": "Represent the question about TV shows to find a paragraph that answers it."
"input": "input": "Which country is Galileo from?"
→ Embedding: [-0.6310919, 1.4309896, -0.85546875, ...]
Step 2:
Compare the similarity
We leave the embeddings of the documents untouched and now obtain the following cosine similarities:
Query vs. German TV show: ~0.632
Query vs. Italian polymath: ~0.512
These new cosine similarities imply that the ranking has indeed changed and the paragraph about the German TV show is
now more relevant. This shows that instructions can help the model understand nuances in the data better
and ultimately lead to embeddings that are more useful for your use-case.
Tips on using the model
- First try and ideally evaluate the model on your data without instructions to see whether performance aligns with your expectations out-of-the-box
- If you decide to use an instruction with the aim of further boosting performance we suggest using this template as a guideline
Template: Represent the [X] to find a [Y] that [describe how the X and Y relate]
- Examples
- Represent the newspaper paragraph to find a newspaper paragraph with the same topic
- Represent the sentence to find another sentence with the same meaning
- In cases where the two texts to compare are different in nature (e.g. query and document) – also called “asymmetric” – we suggest to first add an instruction to query texts only. Again, try and ideally evaluate the model in this setting. Then, if your aim is to further boost performance, we suggest that you add instructions to document texts as well where [X] and [Y] are flipped accordingly.
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]