Instructions to use curiousily/tiny-crypto-sentiment-analysis with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use curiousily/tiny-crypto-sentiment-analysis with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="curiousily/tiny-crypto-sentiment-analysis")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("curiousily/tiny-crypto-sentiment-analysis") model = AutoModelForCausalLM.from_pretrained("curiousily/tiny-crypto-sentiment-analysis") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use curiousily/tiny-crypto-sentiment-analysis with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "curiousily/tiny-crypto-sentiment-analysis" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "curiousily/tiny-crypto-sentiment-analysis", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/curiousily/tiny-crypto-sentiment-analysis
- SGLang
How to use curiousily/tiny-crypto-sentiment-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 "curiousily/tiny-crypto-sentiment-analysis" \ --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": "curiousily/tiny-crypto-sentiment-analysis", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "curiousily/tiny-crypto-sentiment-analysis" \ --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": "curiousily/tiny-crypto-sentiment-analysis", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use curiousily/tiny-crypto-sentiment-analysis with Docker Model Runner:
docker model run hf.co/curiousily/tiny-crypto-sentiment-analysis
Update README.md
Browse files
README.md
CHANGED
|
@@ -13,6 +13,8 @@ to predict the sentiment and subject of an article
|
|
| 13 |
|
| 14 |
## How to Use
|
| 15 |
|
|
|
|
|
|
|
| 16 |
```py
|
| 17 |
import torch
|
| 18 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
@@ -38,3 +40,39 @@ pipe = pipeline(
|
|
| 38 |
return_full_text=False,
|
| 39 |
)
|
| 40 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
## How to Use
|
| 15 |
|
| 16 |
+
Load the model:
|
| 17 |
+
|
| 18 |
```py
|
| 19 |
import torch
|
| 20 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
|
|
|
| 40 |
return_full_text=False,
|
| 41 |
)
|
| 42 |
```
|
| 43 |
+
|
| 44 |
+
Prompt format:
|
| 45 |
+
|
| 46 |
+
```py
|
| 47 |
+
prompt = """
|
| 48 |
+
### Title:
|
| 49 |
+
<YOUR ARTICLE TITLE>
|
| 50 |
+
### Text:
|
| 51 |
+
<YOUR ARTICLE PARAGRAPH>
|
| 52 |
+
### Prediction:
|
| 53 |
+
""".strip()
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Here's an example:
|
| 57 |
+
|
| 58 |
+
```py
|
| 59 |
+
prompt = """
|
| 60 |
+
### Title:
|
| 61 |
+
Bitcoin Price Prediction as BTC Breaks Through $27,000 Barrier Here are Price Levels to Watch
|
| 62 |
+
### Text:
|
| 63 |
+
Bitcoin, the world's largest cryptocurrency by market capitalization, has been making headlines recently as it broke through the $27,000 barrier for the first time. This surge in price has reignited speculation about where Bitcoin is headed next, with many analysts and investors offering their predictions.
|
| 64 |
+
### Prediction:
|
| 65 |
+
""".strip()
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
Get a prediction:
|
| 69 |
+
|
| 70 |
+
```py
|
| 71 |
+
outputs = pipe(prompt)
|
| 72 |
+
print(outputs[0]["generated_text"].strip())
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
```md
|
| 76 |
+
subject: bitcoin
|
| 77 |
+
sentiment: positive
|
| 78 |
+
```
|