Downloads · 30 days
17
12% of all-time downloads
silence09/Qwen2-7B-Instruct-Converted-Llama
Qwen2-7B-Instruct-Converted-Llama is a machine learning model from silence09. 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.
This is a converted model from Qwen2-7B-Instruct to LLaMA format. This conversion allows you to use Qwen2-7B-Instruct as if it were a LLaMA model, which is convenient for some inference use cases. The precision is exc…
Downloads · 30 days
17
12% of all-time downloads
All-time downloads
142
Public
Parameters
7.6B
15.2 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors15.2 GB · 100%
From the Hugging Face model README
This is a converted model from Qwen2-7B-Instruct to LLaMA format. This conversion allows you to use Qwen2-7B-Instruct as if it were a LLaMA model, which is convenient for some inference use cases. The precision is excatly the same as the original model.
You can load the model using the LlamaForCausalLM class as shown below:
from transformers import AutoTokenizer, LlamaForCausalLM
prompt = "Give me a short introduction to large language model."
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": prompt}
]
# we still use the original tokenizer from Qwen2-7B-Instruct
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-7B-Instruct")
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text],return_tensors="pt").cuda()
# Converted LlaMA model
llama_model = LlamaForCausalLM.from_pretrained(
"silence09/Qwen2-7B-Instruct-Converted-Llama",
torch_dtype='auto').cuda()
llama_generated_ids = llama_model.generate(model_inputs.input_ids, max_new_tokens=32, do_sample=False)
llama_generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, llama_generated_ids)
]
llama_response = tokenizer.batch_decode(llama_generated_ids, skip_special_tokens=True)[0]
print(llama_response)
To comare result with the original model, you can use this code
It was converted using the python script available at this repository