Sentence Similarity
sentence-transformers
Safetensors
Transformers
English
Chinese
qwen2
feature-extraction
custom_code
text-embeddings-inference
Instructions to use infly/inf-retriever-v1-1.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use infly/inf-retriever-v1-1.5b with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("infly/inf-retriever-v1-1.5b", trust_remote_code=True) sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use infly/inf-retriever-v1-1.5b with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("infly/inf-retriever-v1-1.5b", trust_remote_code=True) model = AutoModel.from_pretrained("infly/inf-retriever-v1-1.5b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Can't convert to gguf model
#1
by felikz - opened
Using llama.cpp project:
$ python convert_hf_to_gguf.py ../inf-retriever-v1-1.5b
ValueError: Can not map tensor 'embed_tokens.weight'
probably due to missing model.safetensors.index.json ?
It looks like llama.cpp currently only supports converting "Qwen2ForCausalLM" (https://github.com/ggml-org/llama.cpp/blob/193c3e03a63ccda3ac3d6a2999e41e6d1414fe23/convert_hf_to_gguf.py#L2259).
You can try reverting it from "Qwen2Model" to "Qwen2ForCausalLM" before converting.
from transformers import AutoModelForCausalLM, AutoModel, AutoConfig
config = AutoConfig.from_pretrained("../inf-retriever-v1-1.5b")
model_causal = AutoModelForCausalLM.from_config(config)
model = AutoModel.from_pretrained("../inf-retriever-v1-1.5b")
model_causal.model = model
model_causal.save_pretrained("../inf-retriever-v1-1.5b-causal")
That works, thank you!
For anyone googling this:
Make sure you have all files from the repository in place in -causal dir, except original model.safetensors!
felikz changed discussion status to closed