Downloads · 30 days
9
2% of all-time downloads
Jungwonchang/Ko-QWEN-7B-Chat-LoRA
Ko-QWEN-7B-Chat-LoRA is a machine learning model from Jungwonchang. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
Korean Chatbot based on Alibaba's QWEN [](https://colab.research.google.com/drive/1fmcq1YZaIYg-cuCS4aadomutLmzSyEYIscrollTo=6c1edcdc-158d-4043-a7c7-1d145ebf2cd1)
Downloads · 30 days
9
2% of all-time downloads
All-time downloads
436
Public
Repo size
286 MB
Likes
7
Public
Click a slice to open those files.
.safetensors286 MB · 100%
From the Hugging Face model README
Korean Chatbot based on Alibaba's QWEN
(keep in mind that basic colab runtime with T4 GPU will lead to OOM error. Fine-tuned version of Qwen-14b-Chat-Int4 will not have this issue)
This is a instruction-tuned model of 🤗Qwen/Qwen-7B-Chat. The instruction data for fine-tuning was 🤗nlpai-lab/kullm-v2. The model is intended to communicate via Korean, although it preserves its high proficiency in English & Chinese. Currently working on fine-tuning 🤗Qwen-14B-Chat via QLoRA, and this will have better results without OOM error in basic colab Runtime, so STAY TUNED!
알리바바의 QWEN으로 fine-tune한 AI비서 Ko-QWEN을 소개합니다! nlpai-lab/kullm-v2 데이터로 Instruction-tune을 진행했습니다. 한국어로 대화하는 데 초점을 맞췄지만, 영어와 중국어 성능도 여전히 훌륭합니다. 현재 Qwen-14B-Chat-Int4 모델을 QLoRA 학습을 진행중이며, 이는 더 좋은 성능을 보이며 기본 colab runtime에서도 gpu OOM에러가 없을 것으로 예상됩니다!
The Ko-QWEN AI assistant is designed to serve as a versatile tool for individuals and organizations looking to enhance their communication and productivity. The intended uses of the model include:
This model is intended for constructive and ethical applications, such as language learning, cultural exchange, and providing assistance with information and tasks within the bounds of lawful behavior. Uses that are explicitly out of scope and strongly discouraged include:
This model has been trained on a diverse dataset intended to minimize bias; however, as with any AI system, there is a risk of unintended bias in language generation, which could reinforce stereotypes or marginalize certain groups. Furthermore, while the model is proficient in multiple languages, there may be nuances and idiomatic expressions that it does not fully capture, potentially affecting the quality of interaction in certain cultural contexts. The model's responses are also based on patterns in data and may not always provide accurate or reliable information, especially in fast-evolving or specialized knowledge domains.
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. To address these issues, we recommend the following:
Use the code below to get started with the model, or play around with the model in the colab demo
# How to load model and tokenizer
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" if torch.cuda.is_available() else torch.device("cpu")
model_path = "Jungwonchang/Ko-QWEN-7B-Chat-LoRA"
config = PeftConfig.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, trust_remote_code=True, resume_download=True)
model = PeftModel.from_pretrained(model, model_path).to(device)
tokenizer = AutoTokenizer.from_pretrained(
config.base_model_name_or_path, trust_remote_code=True, resume_download=True,
)
# Chat by simply using the Qwen model's .chat() method.
query = "Any question you want to ask"
response, _ = model.chat(query)
# You can also change your system prompt
response, _ = model.chat(query, system="아래는 작업을 설명하는 명령어입니다. 요청을 적절히 완료하는 응답을 작성하세요.")
# You can make your custom chat function if you want to play with various hyperparameters.
# alpaca style single-turn Chat
def qwen_chat_single_turn(model, tokenizer, device, query, system_message="You are a helpful assistant."):
# Define special tokens and newline token
im_start_id = tokenizer.im_start_id
im_end_id = tokenizer.im_end_id
nl_token = tokenizer.encode("\n")[0]
# Function to tokenize individual parts of the conversation
def tokenize_conversation(role, content):
return [im_start_id] + tokenizer.encode(role) + [nl_token] + tokenizer.encode(content) + [im_end_id]
# Start constructing the full conversation context
context_tokens = tokenize_conversation("system", system_message) + [nl_token, nl_token]
# Add the current user query
context_tokens += tokenize_conversation("user", query) + [nl_token, nl_token]
# Add a token indicating the start of the assistant's response
context_tokens += [im_start_id] + tokenizer.encode("assistant") + [nl_token]
# Convert context tokens to a tensor and generate a response
input_ids = torch.tensor(context_tokens).unsqueeze(0).to(device)
generated_ids = model.generate(
input_ids=input_ids,
max_new_tokens=1024,
early_stopping=True,
do_sample=True,
top_k=20,
top_p=0.92,
no_repeat_ngram_size=3,
eos_token_id=im_end_id,
repetition_penalty=1.2,
num_beams=3
)
# Decode the generated response
generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
# Extract only the assistant's response
response = generated_text.split("assistant\n")[-1].strip()
return response
query="Question you want to ask"
response = qwen_chat_single_turn(model, tokenizer, device, query=query,
system_message="아래는 작업을 설명하는 명령어입니다. 요청을 적절히 완료하는 응답을 작성하세요."
)
🤗nlpai-lab/kullm-v2: 150k amount of Korean instruction dataset
The model was fine-tuned using LoRA (Low-Rank Adaptation), which allows for efficient training of large language models by updating only a small set of parameters. The fine-tuning process was conducted on a single node with 2 GPUs, utilizing distributed training to enhance the training efficiency and speed. The lora rank was set to 32, for I only had limited time to access the GPUs.
[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]
A instruction fine-tuned(or SFT) version on Alibaba's QWEN/QWEN-7b
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
[More Information Needed]
[More Information Needed]
[More Information Needed]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
[More Information Needed]
[More Information Needed]
Jungwon Chang
[email protected] [email protected]