Instructions to use textgain/News2Topic-T5-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use textgain/News2Topic-T5-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="textgain/News2Topic-T5-base")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("textgain/News2Topic-T5-base") model = AutoModelForSeq2SeqLM.from_pretrained("textgain/News2Topic-T5-base", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use textgain/News2Topic-T5-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "textgain/News2Topic-T5-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "textgain/News2Topic-T5-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/textgain/News2Topic-T5-base
- SGLang
How to use textgain/News2Topic-T5-base 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 "textgain/News2Topic-T5-base" \ --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": "textgain/News2Topic-T5-base", "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 "textgain/News2Topic-T5-base" \ --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": "textgain/News2Topic-T5-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use textgain/News2Topic-T5-base with Docker Model Runner:
docker model run hf.co/textgain/News2Topic-T5-base
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: text2text-generation
|
| 6 |
+
---
|
| 7 |
+
# Model Card for Model ID
|
| 8 |
+
|
| 9 |
+
## Model Details
|
| 10 |
+
|
| 11 |
+
### Model Description
|
| 12 |
+
|
| 13 |
+
- **Model type:** Text-to-Text Generation
|
| 14 |
+
- **Language(s) (NLP):** English
|
| 15 |
+
- **License:** MIT License
|
| 16 |
+
- **Finetuned from model:** T5 Base Model (Google AI)
|
| 17 |
+
|
| 18 |
+
## Uses
|
| 19 |
+
|
| 20 |
+
The News2Topic T5-base model is designed for automatic generation of topic names from news articles or news-like text. It can be integrated into news aggregation platforms, content management systems, or used for enhancing news browsing and searching experiences by providing concise topics.
|
| 21 |
+
|
| 22 |
+
## How to Get Started with the Model
|
| 23 |
+
|
| 24 |
+
```
|
| 25 |
+
from transformers import pipeline
|
| 26 |
+
|
| 27 |
+
pipe = pipeline("text2text-generation", model="textgain/News2Topic-T5-base")
|
| 28 |
+
|
| 29 |
+
```
|
| 30 |
+
# Example usage
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
news_text = "Your news text here."
|
| 34 |
+
print(pipe(news_text))
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## Training Details
|
| 38 |
+
|
| 39 |
+
### Training Data
|
| 40 |
+
|
| 41 |
+
The News2Topic T5-base model was trained on a 21K sample of the "newsroom" dataset annotated with synthetic data generated by GPT-3.5-turbo
|
| 42 |
+
|
| 43 |
+
### Training Procedure
|
| 44 |
+
|
| 45 |
+
The model was trained for 3 epochs, with a learning rate of 0.00001, a maximum sequence length of 512, and a training batch size of 12.
|
| 46 |
+
|
| 47 |
+
## Citation
|
| 48 |
+
|
| 49 |
+
**BibTeX:**
|
| 50 |
+
```
|
| 51 |
+
@article{Kosar_De Pauw_Daelemans_2024,
|
| 52 |
+
title={Comparative Evaluation of Topic Detection: Humans vs. LLMs}, volume={13},
|
| 53 |
+
url={https://www.clinjournal.org/clinj/article/view/173}, journal={Computational Linguistics in the Netherlands Journal},
|
| 54 |
+
author={Kosar, Andriy and De Pauw, Guy and Daelemans, Walter},
|
| 55 |
+
year={2024},
|
| 56 |
+
month={Mar.},
|
| 57 |
+
pages={91–120} }
|
| 58 |
+
```
|