Views
No views yet
1from transformers import AutoModel, AutoTokenizer
2
3# Load quantized model
4model = AutoModel.from_pretrained(
5 "nomic-embed-code-W4A16-AWQ",
6 trust_remote_code=True
7)
8tokenizer = AutoTokenizer.from_pretrained(
9 "nomic-embed-code-W4A16-AWQ",
10 trust_remote_code=True
11)
12
13# Generate embeddings
14texts = ["Hello world", "Example text"]
15inputs = tokenizer(texts, padding=True, return_tensors="pt")
16embeddings = model(**inputs).last_hidden_state.mean(dim=1)
17
18print(embeddings.shape)1@software{llmcompressor,
2 title = {LLM Compressor},
3 author = {Neural Magic},
4 url = {https://github.com/vllm-project/llm-compressor},
5 year = {2024}
6}