Instructions to use TCHATCHOUA/mistral-finance-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TCHATCHOUA/mistral-finance-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TCHATCHOUA/mistral-finance-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("TCHATCHOUA/mistral-finance-finetuned", device_map="auto") - PEFT
How to use TCHATCHOUA/mistral-finance-finetuned with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TCHATCHOUA/mistral-finance-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TCHATCHOUA/mistral-finance-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TCHATCHOUA/mistral-finance-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TCHATCHOUA/mistral-finance-finetuned
- SGLang
How to use TCHATCHOUA/mistral-finance-finetuned 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 "TCHATCHOUA/mistral-finance-finetuned" \ --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": "TCHATCHOUA/mistral-finance-finetuned", "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 "TCHATCHOUA/mistral-finance-finetuned" \ --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": "TCHATCHOUA/mistral-finance-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use TCHATCHOUA/mistral-finance-finetuned with Docker Model Runner:
docker model run hf.co/TCHATCHOUA/mistral-finance-finetuned
Fiche Modèle pour Mistral-Finance-Finetuned
Ce modèle est une version "fine-tunée" (spécialisée) de Mistral-7B-Instruct-v0.1. Il est expert en Analyse de Sentiment Financier. Il est capable de classer des phrases issues de l'actualité financière en trois catégories : Positive, Negative, ou Neutral.
Détails du Modèle
Description
Ce modèle a été entraîné en utilisant la méthode QLoRA (Quantization + Low-Rank Adaptation) pour adapter le modèle généraliste Mistral 7B au domaine spécifique de la finance. Il a été entraîné sur le jeu de données Financial PhraseBank, spécifiquement sur la partie où 100% des experts humains étaient d'accord sur le sentiment.
- Développé par : TCHATCHOUA
- Type de modèle : Causal Language Model (LLM)
- Langue(s) : Anglais (Dataset et Instructions)
- Licence : Apache-2.0
- Modèle de base : mistralai/Mistral-7B-Instruct-v0.1
Sources
Utilisation
Usage Direct
Le modèle est conçu pour analyser de courts textes financiers (titres de presse, extraits de rapports) et en déduire le sentiment.
Exemple d'entrée :
"Operating profit rose to EUR 10 million from EUR 5 million."
Exemple de sortie :
"Positive"
Limites et Usage hors-périmètre
- Ce modèle N'EST PAS un conseiller financier. Il ne doit pas être utilisé pour prendre des décisions d'investissement réelles.
- Il n'est pas conçu pour générer de longs rapports financiers, mais uniquement pour de l'analyse (classification).
Comment utiliser le modèle (Code Python)
Vous pouvez utiliser le code ci-dessous pour charger le modèle et lancer une analyse :
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
# 1. Charger le modèle de base (Mistral 7B)
base_model_id = "mistralai/Mistral-7B-Instruct-v0.1"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
device_map="auto"
)
# 2. Charger l'adaptateur Fine-Tuné
# Remplacez 'TCHATCHOUA' par votre nom d'utilisateur HF si nécessaire
adapter_model_id = "TCHATCHOUA/mistral-finance-finetuned"
model = PeftModel.from_pretrained(base_model, adapter_model_id)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
# 3. Fonction de prédiction
def predict_sentiment(text):
# Le prompt doit rester en anglais car le modèle a appris ainsi
prompt = f"### Instruction: Analyze the sentiment of the following financial sentence.\n### Input: {text}\n### Response:"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=5, pad_token_id=tokenizer.eos_token_id)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
return result.split("### Response:")[-1].strip()
# Test
print(predict_sentiment("The company reported a decrease in revenue."))
# Résultat attendu : Negative
Model tree for TCHATCHOUA/mistral-finance-finetuned
Base model
mistralai/Mistral-7B-v0.1