Instructions to use WhereIsAI/UAE-Large-V1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use WhereIsAI/UAE-Large-V1 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("WhereIsAI/UAE-Large-V1") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use WhereIsAI/UAE-Large-V1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="WhereIsAI/UAE-Large-V1")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("WhereIsAI/UAE-Large-V1") model = AutoModel.from_pretrained("WhereIsAI/UAE-Large-V1") - Transformers.js
How to use WhereIsAI/UAE-Large-V1 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('feature-extraction', 'WhereIsAI/UAE-Large-V1'); - Notebooks
- Google Colab
- Kaggle
Resource Requirement
Everytime I try to run this model it keeps printing "killed". when I debugged it, it prints out
"Out of memory: Killed process 1221 (python3) total-vm:42467440kB, anon-rss:7566620kB, file-rss:0kB, shmem-rss:4kB, UID:1000 pgtables:27940kB oom_score_adj:0"
Keep in mind: im testing it out using the sample code
from angle_emb import AnglE
angle = AnglE.from_pretrained('WhereIsAI/UAE-Large-V1', pooling_strategy='cls').cuda()
vec = angle.encode('hello world', to_numpy=True)
print(vec)
vecs = angle.encode(['hello world1', 'hello world2'], to_numpy=True)
print(vecs)
and I made sure to install everything as specified by its requirements.txt file
I am running this on vscode using a WSL terminal. Any solutions?
i didn't test it on WSL. So I am not sure whether it is a problem of transformers.
Could you test it using transformers? as follows
import torch
from transformers import AutoModel, AutoTokenizer
model_id = 'WhereIsAI/UAE-Large-V1'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModel.from_pretrained(model_id).cuda()
inputs = 'hello world!'
tok = tokenizer([inputs], return_tensors='pt')
for k, v in tok.items():
tok[k] = v.cuda()
hidden_state = model(**tok).last_hidden_state
vec = hidden_state[:, 0]
print(vec)