Downloads · 30 days
9
0% of all-time downloads
RichardErkhov/llm4fun_-_vietrag-7b-v1.0-gguf
llm4fun_-_vietrag-7b-v1.0-gguf is a machine learning model from RichardErkhov. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
9
0% of all-time downloads
All-time downloads
13.5K
Public
Repo size
76.6 GB
Likes
0
Public
Click a slice to open those files.
.gguf88.7 GB · 100%
From the Hugging Face model README
Quantization made by Richard Erkhov.
vietrag-7b-v1.0 - GGUF
| Name | Quant method | Size |
|---|---|---|
| vietrag-7b-v1.0.Q2_K.gguf | Q2_K | 2.36GB |
| vietrag-7b-v1.0.IQ3_XS.gguf | IQ3_XS | 2.6GB |
| vietrag-7b-v1.0.IQ3_S.gguf | IQ3_S | 2.75GB |
| vietrag-7b-v1.0.Q3_K_S.gguf | Q3_K_S | 2.75GB |
| vietrag-7b-v1.0.IQ3_M.gguf | IQ3_M | 2.9GB |
| vietrag-7b-v1.0.Q3_K.gguf | Q3_K | 3.07GB |
| vietrag-7b-v1.0.Q3_K_M.gguf | Q3_K_M | 3.07GB |
| vietrag-7b-v1.0.Q3_K_L.gguf | Q3_K_L | 3.35GB |
| vietrag-7b-v1.0.IQ4_XS.gguf | IQ4_XS | 3.4GB |
| vietrag-7b-v1.0.Q4_0.gguf | Q4_0 | 3.56GB |
| vietrag-7b-v1.0.IQ4_NL.gguf | IQ4_NL | 3.58GB |
| vietrag-7b-v1.0.Q4_K_S.gguf | Q4_K_S | 3.59GB |
| vietrag-7b-v1.0.Q4_K.gguf | Q4_K | 3.8GB |
| vietrag-7b-v1.0.Q4_K_M.gguf | Q4_K_M | 3.8GB |
| vietrag-7b-v1.0.Q4_1.gguf | Q4_1 | 3.95GB |
| vietrag-7b-v1.0.Q5_0.gguf | Q5_0 | 4.33GB |
| vietrag-7b-v1.0.Q5_K_S.gguf | Q5_K_S | 4.33GB |
| vietrag-7b-v1.0.Q5_K.gguf | Q5_K | 4.45GB |
| vietrag-7b-v1.0.Q5_K_M.gguf | Q5_K_M | 4.45GB |
| vietrag-7b-v1.0.Q5_1.gguf | Q5_1 | 4.72GB |
| vietrag-7b-v1.0.Q6_K.gguf | Q6_K | 5.15GB |
| vietrag-7b-v1.0.Q8_0.gguf | Q8_0 | 6.67GB |
language:
You can check our model card here: llm4fun/vietrag-7b-v1.0
from transformers import GenerationConfig, TextStreamer
from transformers import LlamaForCausalLM, LlamaTokenizer, LlamaConfig
import torch
question = "<your-question>"
context = "<your-context>"
instruction = 'You are an AI assistant. Provide a detailed answer so user don’t need to search outside to understand the answer.'
input = f"Dựa vào một số ngữ cảnh được cho dưới đây, trả lời câu hỏi ở cuối.\n\n{context}\n\nQuestion: {question}"
prompt_template = (
"### System:\n"
"Below is an instruction that describes a task, paired with an input that provides further context. "
"Write a response that appropriately completes the request.\n\n\n\n"
"### Instruction:\n{instruction}\n\n"
"### Input:\n{input}\n\n"
"### Response:\n{output}"
)
prompt = prompt_template.format(instruction=instruction, input=input, output='')
torch_dtype = torch.bfloat16
model_id = "llm4fun/vietrag-7b-v1.0"
device = "cuda"
tokenizer = LlamaTokenizer.from_pretrained(model_id)
model = LlamaForCausalLM.from_pretrained(
model_id,
config=LlamaConfig.from_pretrained(model_id),
torch_dtype=torch_dtype
)
model = model.eval().to(device)
def generate(prompt, max_new_tokens=1024):
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"].to(model.device)
model.eval()
with torch.no_grad():
generation_config = GenerationConfig(
repetition_penalty=1.13,
max_new_tokens=max_new_tokens,
# temperature=0.2,
# top_p=0.95,
# top_k=20,
# bos_token_id=tokenizer.bos_token_id,
# eos_token_id=tokenizer.eos_token_id,
# eos_token_id=0, # for open-end generation.
pad_token_id=tokenizer.pad_token_id,
do_sample=False,
use_cache=True,
return_dict_in_generate=True,
output_attentions=False,
output_hidden_states=False,
output_scores=False,
)
streamer = TextStreamer(tokenizer, skip_prompt=True)
generated = model.generate(
inputs=input_ids,
generation_config=generation_config,
streamer=streamer,
)
gen_tokens = generated["sequences"].cpu()[:, len(input_ids[0]):]
output = tokenizer.batch_decode(gen_tokens)[0]
output = output.split(tokenizer.eos_token)[0]
return output.strip()
output = generate(prompt)
To tweak the model's answering style, feel free to replace the instruction part of the prompt. I reccommend you select one of these following instructions, because they are used during training.
instructions = [
'You are an AI assistant. Provide a detailed answer so user don’t need to search outside to understand the answer.',
'You are an AI assistant. You will be given a task. You must generate a detailed and long answer.',
'You are an AI assistant. User will you give you a task. Your goal is to complete the task as faithfully as you can. While performing the task think step-by-step and justify your steps.',
'You are an smart assistant. Provide a direct, short and exact answer to the following question from its provided context.'
]