Text Generation
Transformers
Safetensors
Korean
llama
news-analysis
sentiment-analysis
summarization
stock-code-identification
advertisement-detection
conversational
text-generation-inference
Instructions to use irene93/Llama3-news-analysis with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use irene93/Llama3-news-analysis with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="irene93/Llama3-news-analysis") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("irene93/Llama3-news-analysis") model = AutoModelForCausalLM.from_pretrained("irene93/Llama3-news-analysis", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use irene93/Llama3-news-analysis with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "irene93/Llama3-news-analysis" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "irene93/Llama3-news-analysis", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/irene93/Llama3-news-analysis
- SGLang
How to use irene93/Llama3-news-analysis 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 "irene93/Llama3-news-analysis" \ --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": "irene93/Llama3-news-analysis", "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 "irene93/Llama3-news-analysis" \ --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": "irene93/Llama3-news-analysis", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use irene93/Llama3-news-analysis with Docker Model Runner:
docker model run hf.co/irene93/Llama3-news-analysis
๋ด์ค ๋ถ์ ๋ชจ๋ธ
์ด ์ ์ฅ์์๋ ์ฃผ์ด์ง ๋ด์ค ๋ณธ๋ฌธ์ ๋ถ์ํ์ฌ ๋ค์์ ์์ ์ ์ํํ๋ ๋ชจ๋ธ์ด ํฌํจ๋์ด ์์ต๋๋ค:
- ์์ฝ(Summarization): ๋ด์ค ๊ธฐ์ฌ์ ์ฃผ์ ๋ด์ฉ์ 1~3์ค๋ก ์์ฝํฉ๋๋ค.
- ๊ฐ์ฑ ๋ถ์(Sentiment Analysis): ๊ธฐ์ฌ ๋ด์ฉ์ ๊ฐ์ฑ์ ๊ธ์ , ๋ถ์ , ์ค๋ฆฝ์ผ๋ก ํ๊ฐํฉ๋๋ค.
- ์ข ๋ชฉ ์ฝ๋ ์ถ์ถ(Stock Code Identification): ์ธ๊ธ๋ ํ์ฌ๋ช ์ ๊ธฐ๋ฐ์ผ๋ก ๊ด๋ จ ์ฃผ์ ์ข ๋ชฉ ์ฝ๋๋ฅผ ์ถ์ถํฉ๋๋ค.
- ๊ด๊ณ ์ฑ ์ฌ๋ถ ํ๋ณ(Advertisement Detection): ๋ณธ๋ฌธ์ด ๊ด๊ณ ์ธ์ง ์ฌ๋ถ๋ฅผ ํ๋ณํฉ๋๋ค.
๋ชจ๋ธ ์ ๋ณด
๋ชจ๋ธ์ meta-llama์ Llama-3.2-3B๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ต ํ์์ผ๋ฉฐ, Hugging Face์ transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
- ๋ชจ๋ธ:
irene93/Llama3-news-analysis - ํ ํฌ๋์ด์ :
AutoTokenizer - ๋ชจ๋ธ ์ํคํ
์ฒ:
AutoModelForCausalLM
์ค์น ๋ฐฉ๋ฒ
๋จผ์ ํ๊ฒฝ์ ์ค์ ํฉ๋๋ค:
pip install torch transformers
์ฌ์ฉ ๋ฐฉ๋ฒ
๋ค์์ ๋ชจ๋ธ์ ์ฌ์ฉํ์ฌ ๋ด์ค ๊ธฐ์ฌ๋ฅผ ๋ถ์ํ๋ ์์ ์ฝ๋์ ๋๋ค:
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# ๋ชจ๋ธ ๋ฐ ํ ํฌ๋์ด์ ๋ก๋
tokenizer = AutoTokenizer.from_pretrained('irene93/Llama3-news-analysis')
model = AutoModelForCausalLM.from_pretrained('irene93/Llama3-news-analysis')
model = torch.nn.DataParallel(model).cuda()
device = "cuda:0"
user_content = """ํํ์์ด๋ก์คํ์ด์ค๊ฐ โ๋ฐ๋ ๋ก๋ณดํฑ์คโ์ ์ธ๊ณ ์ต๊ณ ์ ๋ฌด์ธ์ฐจ๋ ๊ฐ๋ฐ์ ๋์ ๋ค.
ํํ์์ด๋ก์คํ์ด์ค๋ 19์ผ ์ ๋ฝ ์ต๋์ ๋ฌด์ธ์ฐจ๋(UGV) ๊ธฐ์
์ธ ๋ฐ๋ ๋ก๋ณดํฑ์ค์ โIDEX 2025โ์์ ์ต์ ๊ถค๋ํ UGV์ธ T-RCV(Tracked-Robotic Combat Vehicle)์ ๊ณต๋๊ฐ๋ฐ ๋ฐ ๊ธ๋ก๋ฒ์์ฅ ๊ณต๋ต์ ์ํ ์ ๋ต์ ํํธ๋์ญ์ ํ๋ํ๋ค๋ ๋ด์ฉ์ ์ํด๊ฐ์๋ฅผ ์ฒด๊ฒฐํ๋ค๊ณ ๋ฐํ๋ค.
์์คํ ๋์์ โ๋ฐ๋ ๋ก๋ณดํฑ์คโ๋ ๋ฏธ๊ตญ, ์๊ตญ, ํ๋์ค ๋ฑ ๋ถ๋์์์กฐ์ฝ๊ธฐ๊ตฌ(NATO) 8๊ฐ๊ตญ์ ํฌํจํ ์ด 16๊ฐ๊ตญ์ ๊ถค๋ํ UGV๋ฅผ ๊ณต๊ธํ๋ ๋ฑ ๊ธ๋ก๋ฒ UGV์ ํ์คํ๋ฅผ ์ฃผ๋ํ๋ ์ธ๊ณ ์ต๊ณ ์์ค์ ๊ธฐ์ ์ ๋ณด์ ํ๊ณ ์๋ค.
ํํ์์ด๋ก์คํ์ด์ค๋ ์ฐจ๋ฅํ UGV โ์๋ฆฌ์จ์ค๋ฉงโ์ ํตํด ๋ฏธ๊ตฐ์ใ
ํด์ธ๋น๊ต์ฑ๋ฅ์ํ(FCT)์ ์ฑ๊ณต์ ์ผ๋ก ์ํํ๊ณ , ์ฐจ์ธ๋ UGV์ธ โ๊ทธ๋ฐํธ(GRUNT)โ๋ฅผ ์์ฒด ๊ฐ๋ฐํ๋ ๋ฑ ๊ธ๋ก๋ฒ ์์ฅ์์ ๊ธฐ์ ๋ ฅ์ ์ธ์ ๋ฐ์ผ๋ฉด์ ์ฌํด ํ๊ตญ ์ก๊ตฐ์ ๋ค๋ชฉ์ ๋ฌด์ธ์ฐจ๋ ๊ตฌ๋งค์ฌ์
์ ์ ์ ์ ์๋๊ณ ์๋ค.
ํํ์์ด๋ก์คํ์ด์ค ์ธก์ โ์์ฌ ํ๋ ฅ์ ๋ฐํ์ผ๋ก ๊ตญ๋ด์ธ ๊ณ ๊ฐ๋ค์๊ฒ ๋น ๋ฅด๊ฒ ๋ณํํ๋ ํ๋ ์ ํฌ ํ๊ฒฝ์ ๋์ํ ์๋ก์ด ๋์์ ์ ์ํ๊ฒ ๋คโ๊ณ ํ๋ค.
๋ฐ๋ ๋ก๋ณดํฑ์ค ์ธก๋ โ์์ฌ์ ํ์ ์ ์ธ ๊ธฐ์ ๊ณผ ํ๋ถํ ๊ธ๋ก๋ฒ ์์ฅ ๊ฒฝํ์ ๋ฐํ์ผ๋ก ์ต์ฒจ๋จ ๋ฌด์ธํ ์๋ฃจ์
๊ฐ๋ฐ์ ์ต์ ์ ๋คํ๊ฒ ๋คโ๊ณ ๋งํ๋ค."""
messages = [
{"role": "system", "content": "๋น์ ์ ์ฃผ์ด์ง ๋ด์ค๋ฅผ ๋ถ์ํ๋ ์ฑ๋ด์
๋๋ค. **์ง์์ฌํญ**:- ์ฃผ์ด์ง ๋ด์ค์ ๋ํ์ฌ summary, advr, stk_code, sent_score ๋ถ์ํ๊ณ json ํํ๋ก ์ถ๋ ฅํ์ธ์. - summary๋ 1~3์ค ์ฌ์ด๋ก ์์ฑํฉ๋๋ค.- advr๋ ํด๋น ๋ณธ๋ฌธ์ด ๊ด๊ณ ๋ฉด 1 ๊ด๊ณ ๊ฐ ์๋๊ฒฝ์ฐ์ 0 ์ผ๋ก ์ ์ 1๊ฐ์ ๊ฐ์ผ๋ก ์ถ๋ ฅํ์ธ์.- stk_code๋ ํด๋น ๋ณธ๋ฌธ์์ ์ธ๊ธ๋ ์ข
๋ชฉ๋ช
์ ์ฐพ๊ณ , ๊ทธ ์ข
๋ชฉ๋ช
์ ์ข
๋ชฉ ์ฝ๋๋ฅผ ์ฐพ์ ํ์ด์ฌ ๋ฆฌ์คํธ ํํ๋ก ์์ฑํ์ธ์. - sent_score๋ ํด๋น ๋ณธ๋ฌธ์ด ๊ธ์ ์ ์ผ๊ฒฝ์ฐ 1 ๋ถ์ ์ ์ผ๊ฒฝ์ฐ -1 , ๊ธ์ ์ ์ด์ง๋ ๋ถ์ :์ ์ด์ง๋ ์์๊ฒฝ์ฐ 0 ์ผ๋ก ์ ์ 1๊ฐ์ ๊ฐ์ ์ถ๋ ฅํ์ธ์ - ๋ณธ๋ฌธ: ์ด ์ฃผ์ด์ง๋ฉด ๊ฒฐ๊ณผ: ๋ค์์ json ํํ๋ก ์์ฑํ์ธ์"},
{"role": "user", "content": user_content}
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(device)
terminators = [
tokenizer.eos_token_id,
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.module.generate(
input_ids,
max_new_tokens=2048,
eos_token_id=terminators,
do_sample=False,
)
response = outputs[0][input_ids.shape[-1]:]
print(tokenizer.decode(response, skip_special_tokens=True))
์์ ์ถ๋ ฅ
{
'summary': 'ํํ์์ด๋ก์คํ์ด์ค๊ฐ ๋ฐ๋ ๋ก๋ณดํฑ์ค์ ํ๋ ฅํด ๋ฌด์ธ์ฐจ๋ ๊ฐ๋ฐ์ ๋์ฐ์ต๋๋ค.',
'advr_tp': '0',
'stk_code': ['012450'],
'sent_score': 1
}
์๊ตฌ ์ฌํญ
torchtransformers
๋ผ์ด์ ์ค
์ด ํ๋ก์ ํธ๋ MIT ๋ผ์ด์ ์ค๋ฅผ ๋ฐ๋ฆ ๋๋ค.
- Downloads last month
- 16