Model Card: vi-gemma-2b-RAG
(English below)
TiαΊΏng Viα»t (Vietnamese)
Mô tả mô hình:
vi-gemma-2b-RAG lΓ mα»t mΓ΄ hΓ¬nh ngΓ΄n ngα»― lα»n Δược tinh chα»nh tα»« mΓ΄ hΓ¬nh cΖ‘ sα» google/gemma-1.1-2b-it sα» dα»₯ng kα»Ή thuαΊt LoRA. MΓ΄ hΓ¬nh Δược huαΊ₯n luyα»n trΓͺn tαΊp dα»― liα»u tiαΊΏng Viα»t vα»i mα»₯c tiΓͺu cαΊ£i thiα»n khαΊ£ nΔng xα» lΓ½ ngΓ΄n ngα»― tiαΊΏng Viα»t vΓ nΓ’ng cao hiα»u suαΊ₯t cho cΓ‘c tΓ‘c vα»₯ truy xuαΊ₯t thΓ΄ng tin mα» (Retrieval Augmented Generation - RAG).
Mα»₯c ΔΓch sα» dα»₯ng:
MΓ΄ hΓ¬nh vi-gemma-2b-RAG phΓΉ hợp cho cΓ‘c tΓ‘c vα»₯ sau:
- TrαΊ£ lα»i cΓ’u hα»i dα»±a trΓͺn ngα»― cαΊ£nh tiαΊΏng Viα»t.
- TΓ³m tαΊ―t vΔn bαΊ£n tiαΊΏng Viα»t.
- Dα»ch mΓ‘y tiαΊΏng Viα»t.
- VΓ cΓ‘c tΓ‘c vα»₯ tαΊ‘o vΔn bαΊ£n tiαΊΏng Viα»t khΓ‘c.
Giα»i hαΊ‘n:
MαΊ·c dΓΉ ΔΓ£ Δược tinh chα»nh cho tiαΊΏng Viα»t, vi-gemma-2b-RAG vαΊ«n cΓ³ thα» gαΊ·p phαΊ£i mα»t sα» hαΊ‘n chαΊΏ:
- CΓ³ thα» tαΊ‘o ra thΓ΄ng tin sai lα»ch hoαΊ·c khΓ΄ng chΓnh xΓ‘c.
- CΓ³ thα» thα» hiα»n thΓ nh kiαΊΏn ββhoαΊ·c quan Δiα»m khΓ΄ng phΓΉ hợp.
- Hiα»u suαΊ₯t cΓ³ thα» bα» αΊ£nh hΖ°α»ng bα»i chαΊ₯t lượng của dα»― liα»u ΔαΊ§u vΓ o.
CΓ‘ch sα» dα»₯ng:
DΖ°α»i ΔΓ’y chΓΊng tΓ΄i chia sαΊ» mα»t sα» ΔoαΊ‘n mΓ£ vα» cΓ‘ch bαΊ―t ΔαΊ§u nhanh chΓ³ng Δα» sα» dα»₯ng mΓ΄ hΓ¬nh. TrΖ°α»c tiΓͺn, hΓ£y ΔαΊ£m bαΊ£o ΔΓ£ cΓ i ΔαΊ·t pip install -U transformers
, sau ΔΓ³ sao chΓ©p ΔoαΊ‘n mΓ£ tα»« phαΊ§n cΓ³ liΓͺn quan ΔαΊΏn usecase của bαΊ‘n.
ChΓΊng tΓ΄i khuyαΊΏn nghα» sα» dα»₯ng torch.bfloat16
lΓ m mαΊ·c Δα»nh.
# pip install transformers torch accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Khα»i tαΊ‘o tokenizer vΓ model tα»« checkpoint ΔΓ£ lΖ°u
tokenizer = AutoTokenizer.from_pretrained("himmeow/vi-gemma-2b-RAG")
model = AutoModelForCausalLM.from_pretrained(
"himmeow/vi-gemma-2b-RAG",
device_map="auto",
torch_dtype=torch.bfloat16
)
# Sα» dα»₯ng GPU nαΊΏu cΓ³
if torch.cuda.is_available():
model.to("cuda")
# Δα»nh dαΊ‘ng prompt cho model
prompt = """
### Instruction and Input:
Dα»±a vΓ o ngα»― cαΊ£nh/tΓ i liα»u sau:
{}
HΓ£y trαΊ£ lα»i cΓ’u hα»i: {}
### Response:
{}
"""
# ChuαΊ©n bα» dα»― liα»u ΔαΊ§u vΓ o
input_data = """
Short Tandem Repeats (STRs) lΓ cΓ‘c trΓ¬nh tα»± DNA lαΊ·p lαΊ‘i ngαΊ―n (2- 6 nucleotides) xuαΊ₯t hiα»n phα» biαΊΏn trong hα» gen của con ngΖ°α»i. CΓ‘c trΓ¬nh tα»± nΓ y cΓ³ tΓnh Δa hΓ¬nh rαΊ₯t cao trong tα»± nhiΓͺn, Δiα»u nΓ y khiαΊΏn cΓ‘c STRs trα» thΓ nh nhα»―ng markers di truyα»n rαΊ₯t quan trα»ng trong nghiΓͺn cα»©u bαΊ£n Δα» gen ngΖ°α»i vΓ chuαΊ©n ΔoΓ‘n bα»nh lΓ½ di truyα»n cΕ©ng nhΖ° xΓ‘c Δα»nh danh tΓnh trong lΔ©nh vα»±c phΓ‘p y.
CΓ‘c STRs trα» nΓͺn phα» biαΊΏn tαΊ‘i cΓ‘c phΓ²ng xΓ©t nghiα»m phΓ‘p y bα»i vΓ¬ viα»c nhΓ’n bαΊ£n vΓ phΓ’n tΓch STRs chα» cαΊ§n lượng DNA rαΊ₯t thαΊ₯p ngay cαΊ£ khi α» dαΊ‘ng bα» phΓ’n hủy viα»c Δinh danh vαΊ«n cΓ³ thα» Δược thα»±c hiα»n thΓ nh cΓ΄ng. HΖ‘n nα»―a viα»c phΓ‘t hiα»n vΓ ΔΓ‘nh giΓ‘ sα»± nhiα»
m DNA mαΊ«u trong cΓ‘c mαΊ«u vαΊt cΓ³ thα» Δược giαΊ£i quyαΊΏt nhanh vα»i kαΊΏt quαΊ£ phΓ’n tΓch STRs. α» Hoa Kα»³ hiα»n nay, tα»« bα» 13 markers nay ΔΓ£ tΔng lΓͺn 20 markers chΓnh Δang Δược sα» dα»₯ng Δα» tαΊ‘o ra mα»t cΖ‘ sα» dα»― liα»u DNA trΓͺn toΓ n ΔαΊ₯t nΖ°α»c Δược gα»i lΓ The FBI Combined DNA Index System (Expaned CODIS).
CODIS vΓ cΓ‘c cΖ‘ sα» dα»― liα»u DNA tΖ°Ζ‘ng tα»± Δang Δược sα» dα»₯ng thα»±c sα»± thΓ nh cΓ΄ng trong viα»c liΓͺn kαΊΏt cΓ‘c hα» sΖ‘ DNA tα»« cΓ‘c tα»i phαΊ‘m vΓ cΓ‘c bαΊ±ng chα»©ng hiα»n trΖ°α»ng vα»₯ Γ‘n. KαΊΏt quαΊ£ Δα»nh danh STRs cΕ©ng Δược sα» dα»₯ng Δα» hα» trợ hΓ ng trΔm nghΓ¬n trΖ°α»ng hợp xΓ©t nghiα»m huyαΊΏt thα»ng cha con mα»i nΔm'
"""
query = "HΓ£y cho tΓ΄i biαΊΏt mα»t sα» tΓnh chαΊ₯t của STRs Δược dΓΉng Δα» lΓ m gΓ¬?"
# Δα»nh dαΊ‘ng input text
input_text = prompt.format(input_data, query," ")
# MΓ£ hΓ³a input text thΓ nh input ids
input_ids = tokenizer(input_text, return_tensors="pt")
# Sα» dα»₯ng GPU cho input ids nαΊΏu cΓ³
if torch.cuda.is_available():
input_ids = input_ids.to("cuda")
# TαΊ‘o vΔn bαΊ£n bαΊ±ng model
outputs = model.generate(
**input_ids,
max_new_tokens=500,
no_repeat_ngram_size=5, # NgΔn chαΊ·n lαΊ·p lαΊ‘i cΓ‘c cα»₯m tα»« 5 gram
# do_sample=True, # KΓch hoαΊ‘t chαΊΏ Δα» tαΊ‘o vΔn bαΊ£n dα»±a trΓͺn lαΊ₯y mαΊ«u. Trong chαΊΏ Δα» nΓ y, model sαΊ½ chα»n ngαΊ«u nhiΓͺn token tiαΊΏp theo dα»±a trΓͺn xΓ‘c suαΊ₯t Δược tΓnh tα»« phΓ’n phα»i xΓ‘c suαΊ₯t của cΓ‘c token.
# temperature=0.7, # GiαΊ£m temperature Δα» kiα»m soΓ‘t tΓnh ngαΊ«u nhiΓͺn
# early_stopping=True, # Dα»«ng tαΊ‘o vΔn bαΊ£n khi tΓ¬m thαΊ₯y kαΊΏt thΓΊc phΓΉ hợp
)
# GiαΊ£i mΓ£ vΓ in kαΊΏt quαΊ£
print(tokenizer.decode(outputs[0]))
'''
<bos>
### Instruction and Input:
Dα»±a vΓ o ngα»― cαΊ£nh/tΓ i liα»u sau:
Short Tandem Repeats (STRs) lΓ cΓ‘c trΓ¬nh tα»± DNA lαΊ·p lαΊ‘i ngαΊ―n (2- 6 nucleotides) xuαΊ₯t hiα»n phα» biαΊΏn trong hα» gen của con ngΖ°α»i. CΓ‘c trΓ¬nh tα»± nΓ y cΓ³ tΓnh Δa hΓ¬nh rαΊ₯t cao trong tα»± nhiΓͺn, Δiα»u nΓ y khiαΊΏn cΓ‘c STRs trα» thΓ nh nhα»―ng markers di truyα»n rαΊ₯t quan trα»ng trong nghiΓͺn cα»©u bαΊ£n Δα» gen ngΖ°α»i vΓ chuαΊ©n ΔoΓ‘n bα»nh lΓ½ di truyα»n cΕ©ng nhΖ° xΓ‘c Δα»nh danh tΓnh trong lΔ©nh vα»±c phΓ‘p y.
CΓ‘c STRs trα» nΓͺn phα» biαΊΏn tαΊ‘i cΓ‘c phΓ²ng xΓ©t nghiα»m phΓ‘p y bα»i vΓ¬ viα»c nhΓ’n bαΊ£n vΓ phΓ’n tΓch STRs chα» cαΊ§n lượng DNA rαΊ₯t thαΊ₯p ngay cαΊ£ khi α» dαΊ‘ng bα» phΓ’n hủy viα»c Δinh danh vαΊ«n cΓ³ thα» Δược thα»±c hiα»n thΓ nh cΓ΄ng. HΖ‘n nα»―a viα»c phΓ‘t hiα»n vΓ ΔΓ‘nh giΓ‘ sα»± nhiα»
m DNA mαΊ«u trong cΓ‘c mαΊ«u vαΊt cΓ³ thα» Δược giαΊ£i quyαΊΏt nhanh vα»i kαΊΏt quαΊ£ phΓ’n tΓch STRs. α» Hoa Kα»³ hiα»n nay, tα»« bα» 13 markers nay ΔΓ£ tΔng lΓͺn 20 markers chΓnh Δang Δược sα» dα»₯ng Δα» tαΊ‘o ra mα»t cΖ‘ sα» dα»― liα»u DNA trΓͺn toΓ n ΔαΊ₯t nΖ°α»c Δược gα»i lΓ The FBI Combined DNA Index System (Expaned CODIS).
CODIS vΓ cΓ‘c cΖ‘ sα» dα»― liα»u DNA tΖ°Ζ‘ng tα»± Δang Δược sα» dα»₯ng thα»±c sα»± thΓ nh cΓ΄ng trong viα»c liΓͺn kαΊΏt cΓ‘c hα» sΖ‘ DNA tα»« cΓ‘c tα»i phαΊ‘m vΓ cΓ‘c bαΊ±ng chα»©ng hiα»n trΖ°α»ng vα»₯ Γ‘n. KαΊΏt quαΊ£ Δα»nh danh STRs cΕ©ng Δược sα» dα»₯ng Δα» hα» trợ hΓ ng trΔm nghΓ¬n trΖ°α»ng hợp xΓ©t nghiα»m huyαΊΏt thα»ng cha con mα»i nΔm'
HΓ£y trαΊ£ lα»i cΓ’u hα»i: HΓ£y cho tΓ΄i biαΊΏt mα»t sα» tΓnh chαΊ₯t của STRs Δược dΓΉng Δα» lΓ m gΓ¬?
### Response:
STRs Δược sα» dα»₯ng Δα» xΓ‘c Δα»nh danh tΓnh, chuαΊ©n ΔoΓ‘n bα»nh lΓ½ vΓ xΓ‘c Δα»nh bα»nh lΓ½ di truyα»n.
<eos>
'''
HuαΊ₯n luyα»n:
- MΓ΄ hΓ¬nh cΖ‘ sα»: google/gemma-1.1-2b-it
- TαΊp dα»― liα»u: lamhieu/mabrycodes_dialogue_vi
- PhΖ°Ζ‘ng phΓ‘p tinh chα»nh: LoRA, PEFT vα»i Unsloth
Model Card: vi-gemma-2b-RAG
English
Model Description:
vi-gemma-2b-RAG is a large language model fine-tuned from the base model google/gemma-1.1-2b-it using LoRA. The model is trained on a Vietnamese dataset to improve its Vietnamese language processing capabilities and enhance its performance for Retrieval Augmented Generation (RAG) tasks.
Intended Use:
The vi-gemma-2b-RAG model is suitable for tasks such as:
- Vietnamese question answering.
- Vietnamese text summarization.
- Vietnamese machine translation.
- And other Vietnamese text generation tasks.
Limitations:
While fine-tuned for Vietnamese, vi-gemma-2b-RAG may still have some limitations:
- It may generate incorrect or misleading information.
- It may exhibit biases or inappropriate opinions.
- Its performance may be affected by the quality of the input data.
How to Use:
Usage
Below we share some code snippets on how to get quickly started with running the model. First make sure to pip install -U transformers
, then copy the snippet from the section that is relevant for your usecase.
We recommend torch.bfloat16
as the default dtype.
# pip install transformers torch accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Initialize the tokenizer and model from the saved checkpoint
tokenizer = AutoTokenizer.from_pretrained("himmeow/vi-gemma-2b-RAG")
model = AutoModelForCausalLM.from_pretrained(
"himmeow/vi-gemma-2b-RAG",
device_map="auto",
torch_dtype=torch.bfloat16
)
# Use GPU if available
if torch.cuda.is_available():
model.to("cuda")
# Define the prompt format for the model
prompt = """
### Instruction and Input:
Based on the following context/document:
{}
Please answer the question: {}
### Response:
{}
"""
# Prepare the input data
input_data = """
Short Tandem Repeats (STRs) are short (2-6 nucleotides) repeating DNA sequences that are widespread in the human genome. These sequences are highly polymorphic in nature, which makes STRs very important genetic markers in human gene mapping and diagnosis of hereditary diseases as well as identification in the field of forensics.
STRs have become popular in forensic laboratories because the replication and analysis of STRs requires very small amounts of DNA, even in decomposed form, identification can still be performed successfully. Furthermore, the detection and assessment of sample DNA contamination in specimens can be quickly resolved with STR analysis results. In the United States today, the set of 13 markers has now been increased to 20 main markers being used to create a nationwide DNA database called The FBI Combined DNA Index System (Expaned CODIS).
CODIS and similar DNA databases are being used very successfully in linking DNA records from criminals and crime scene evidence. STR identification results are also used to support hundreds of thousands of paternity test cases each year.'
"""
query = "Tell me what are some properties of STRs used for?"
# Format the input text
input_text = prompt.format(input_data, query," ")
# Encode the input text into input ids
input_ids = tokenizer(input_text, return_tensors="pt")
# Use GPU for input ids if available
if torch.cuda.is_available():
input_ids = input_ids.to("cuda")
# Generate text using the model
outputs = model.generate(
**input_ids,
max_new_tokens=500, # Limit the number of tokens generated
no_repeat_ngram_size=5, # Prevent repetition of 5-gram phrases
# do_sample=True,
# temperature=0.7, # Adjust the randomness of the generated text
# early_stopping=True, # Stop generating text when a suitable ending is found
)
# Decode and print the results
print(tokenizer.decode(outputs[0]))
Training:
- Base Model: google/gemma-1.1-2b-it
- Dataset: lamhieu/mabrycodes_dialogue_vi
- Fine-tuning Method: LoRA, PEFT and Unsloth
Using example repository: https://github.com/Martincrux/Vietnamese-RAG-system-building-with-vi-gemma-2b-RAG-and-halong_embedding
Uploaded model
- Developed by: hiieu, himmeow the coder, cuctrinh
- License: apache-2.0
- Finetuned from model : unsloth/gemma-1.1-2b-it-bnb-4bit
This gemma model was trained 2x faster with Unsloth and Huggingface's TRL library.
- Downloads last month
- 201
Model tree for ricepaper/vi-gemma-2b-RAG
Base model
unsloth/gemma-1.1-2b-it-bnb-4bit