Downloads · 30 days
68
3% of all-time downloads
mm/gte-Qwen2-7B-instruct-gguf
gte-Qwen2-7B-instruct-gguf is a machine learning model from mm. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
GGUF conversion of Alibaba-NLP/gte-Qwen2-7B-instruct
Downloads · 30 days
68
3% of all-time downloads
All-time downloads
2.1K
Public
Repo size
61.8 GB
Likes
2
Public
Click a slice to open those files.
.gguf61.8 GB · 100%
From the Hugging Face model README
GGUF conversion of Alibaba-NLP/gte-Qwen2-7B-instruct
Avaiable formats:
Requires: llama-cpp-python
from functools import partial
import numpy as np
from llama_cpp import Llama
max_length = 512
model = Llama.from_pretrained(
repo_id="mm/gte-Qwen2-7B-instruct-gguf",
filename="*Q4_K.gguf", # Choose from the avaiable formats,
embedding=True,
n_ctx=max_length,
n_batch=max_length,
flash_attn=True,
verbose=False,
)
model.tokenize = partial(model.tokenize, special=True)
def calc_emb(s: str):
if len(model.tokenize(s.encode())) > max_length - 1:
print(
"The output will be calculated with truncation because of the length exceeding."
)
v = model.embed(s, normalize=True, truncate=True)
return np.asarray(v[-1])
s = "今日の天気は?"
t = "本日の天候は?"
print(f"cossim({s}, {t}) = {(calc_emb(s) * calc_emb(t)).sum()}")