llk010502/fingpt-sentiment
Viewer • Updated • 76.8k • 6 • 1
How to use llk010502/llama3.1-8B-financial_sentiment with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="llk010502/llama3.1-8B-financial_sentiment") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("llk010502/llama3.1-8B-financial_sentiment", dtype="auto")How to use llk010502/llama3.1-8B-financial_sentiment with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "llk010502/llama3.1-8B-financial_sentiment"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "llk010502/llama3.1-8B-financial_sentiment",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/llk010502/llama3.1-8B-financial_sentiment
How to use llk010502/llama3.1-8B-financial_sentiment with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "llk010502/llama3.1-8B-financial_sentiment" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "llk010502/llama3.1-8B-financial_sentiment",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "llk010502/llama3.1-8B-financial_sentiment" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "llk010502/llama3.1-8B-financial_sentiment",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use llk010502/llama3.1-8B-financial_sentiment with Docker Model Runner:
docker model run hf.co/llk010502/llama3.1-8B-financial_sentiment
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 "llk010502/llama3.1-8B-financial_sentiment" \
--host 0.0.0.0 \
--port 30000# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "llk010502/llama3.1-8B-financial_sentiment",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'This model is a fine-tuned version of Meta's Llama-3.1-8B, tailored for financial sentiment analysis tasks. It leverages LoRA and 8-bit quantization techniques to achieve efficient performance while reducing computational overhead.
Use the following code to load the model:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Base and fine-tuned model
base_model = "meta-llama/Llama-3.1-8B"
peft_model = "llk010502/llama3.1-8B-financial_sentiment"
# Load the base model
model = AutoModelForCausalLM.from_pretrained(
base_model,
trust_remote_code=True,
device_map="auto"
)
# Load the tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
# Load the fine-tuned model
model = PeftModel.from_pretrained(model, peft_model)
model = model.eval()
Base model
meta-llama/Llama-3.1-8B
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "llk010502/llama3.1-8B-financial_sentiment" \ --host 0.0.0.0 \ --port 30000# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "llk010502/llama3.1-8B-financial_sentiment", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'