Instructions to use sjbaek/gemma2-2b-it-korean-dialect with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sjbaek/gemma2-2b-it-korean-dialect with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sjbaek/gemma2-2b-it-korean-dialect") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sjbaek/gemma2-2b-it-korean-dialect") model = AutoModelForCausalLM.from_pretrained("sjbaek/gemma2-2b-it-korean-dialect") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use sjbaek/gemma2-2b-it-korean-dialect with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sjbaek/gemma2-2b-it-korean-dialect" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sjbaek/gemma2-2b-it-korean-dialect", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sjbaek/gemma2-2b-it-korean-dialect
- SGLang
How to use sjbaek/gemma2-2b-it-korean-dialect with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sjbaek/gemma2-2b-it-korean-dialect" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sjbaek/gemma2-2b-it-korean-dialect", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sjbaek/gemma2-2b-it-korean-dialect" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sjbaek/gemma2-2b-it-korean-dialect", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sjbaek/gemma2-2b-it-korean-dialect with Docker Model Runner:
docker model run hf.co/sjbaek/gemma2-2b-it-korean-dialect
📄 Model Card for Model ID
Gemma2 2b 한국어 방언 통역기 v0.2.0
📝 Model Description
Gemma2 2b 한국어 방언 통역기는 한국어 사투리를 표준어로 번역하거나 표준어를 한국어 사투리로 변환하는 프로젝트의 일환으로 개발된 모델입니다.
Gemma2 2b it 모델을 사용하여 강력한 자연어 처리 기능을 제공하며, QLoRa 기법으로 파인튜닝하여 제작되었습니다.
소형 LLM을 사용함으로써, 비용 대비 효과적인 방식으로 사투리 변환 성능을 달성할 수 있습니다.
📚 사용처 | Uses
이 모델은 한국어 방언을 표준 한국어로 번역하거나 그 반대로 번역하는 데 직접 사용할 수 있습니다. 음성 인식 및 번역 도구를 개발하는 교육자, 언어학자, 개발자에게 유용할 수 있습니다.
✍️ 예시 | Examples
| 입력 문장 | 방언: 게난 저 어머니 더 나이 먹어가기 전에 여기 와야 될 건디 | 표준어: 그러니깐 저 어머니 더 나이 먹어가기 전에 여기 와야 될 건데 |
|---|---|---|
| 방언 통역기 출력 | 표준어: 그러니까 저 어머니 더 나이 먹어가기 전에 여기 와야 될 건데 | 방언: 게난 저 어멍 더 나이 먹어가기 전에 여기 와야 될 건디 |
| 입력 문장 | 방언: 자이 폴에 독솔 막 난 거 보난 언 생이우다 | 표준어: 재 팔에 닭살이 막 난 거 보니, 추운 모양이다 |
|---|---|---|
| 방언 통역기 출력 | 표준어: 쟤 팔에 닭살이 많이 난 거 보니까 추운 모양입니다 | 방언: 재 폴에 독솔 막 난 거 보난 언 생이우다 |
⚠️ 한계점 | Bias, Risks, and Limitations
이 모델은 현재 제주 방언에 초점을 맞춘 특정 데이터 세트에 맞춰 미세 조정되었기 때문에 다른 방언이나 언어에 대한 성능이 제한될 수 있습니다.
향후 버전에서 다양한 방언에 대한 지원을 추가할 예정입니다.(충청, 전라, 경상, 강원)
🚀 사용법 | How to Get Started with the Model
import transformers
import torch
model_id = "sjbaek/gemma2-2b-it-korean-dialect"
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id, add_eos_token=True)
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
tokenizer=tokenizer,
torch_dtype=torch.float16,
device_map="auto",
max_new_tokens = 512,
)
def dialect_to_standard(text, dialect_type):
return [
{
"role":"user",
"content": "Convert the following sentence or word which is {}'s dialect to standard Korean:\n\n{}".format(dialect_type, text)
}
]
def standard_to_dialect(text, dialect_type):
return [
{
"role":"user",
"content": "Convert the following sentence or word which is standard Korean to {}'s dialect :\n\n{}".format(dialect_type, text)
}
]
outputs = pipeline(
dialect_to_standard("우리 동생도 요번에 월요일날 미깡 타카부댄 내려왔당 못 타난", "제주도"),
do_sample=True,
temperature=0.1,
top_p=0.90,
add_special_tokens=True
)
print(outputs[0]["generated_text"][-1])
# {'role': 'assistant', 'content': '우리 동생도 요번에 월요일날 귤 타고 왔다가 못 타니까'}
outputs = pipeline(
standard_to_dialect("그러니깐 저 어머니 더 나이 먹어가기 전에 여기 와야 될 건데", "제주도"),
do_sample=True,
temperature=0.1,
top_p=0.90,
add_special_tokens=True
)
print(outputs[0]["generated_text"][-1])
# {'role': 'assistant', 'content': '게난 저 어멍 더 나이 먹어가기 전에 여기 와야 될 건디'}
📊 사용 데이터셋 | Training Data
🔜 향후 계획 | TO DO
- 충청도 방언 변환 기능 (v0.3.0)
- 전라도 방언 변환 기능 (v0.4.0)
- 경상도 방언 변환 기능 (v0.5.0)
- 강원도 방언 변환 기능 (v1.0.0)
- Downloads last month
- 9