Instructions to use KomeijiForce/bart-large-emojilm-e2t with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KomeijiForce/bart-large-emojilm-e2t with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="KomeijiForce/bart-large-emojilm-e2t")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("KomeijiForce/bart-large-emojilm-e2t") model = AutoModelForSeq2SeqLM.from_pretrained("KomeijiForce/bart-large-emojilm-e2t") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KomeijiForce/bart-large-emojilm-e2t with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KomeijiForce/bart-large-emojilm-e2t" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KomeijiForce/bart-large-emojilm-e2t", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/KomeijiForce/bart-large-emojilm-e2t
- SGLang
How to use KomeijiForce/bart-large-emojilm-e2t 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 "KomeijiForce/bart-large-emojilm-e2t" \ --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": "KomeijiForce/bart-large-emojilm-e2t", "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 "KomeijiForce/bart-large-emojilm-e2t" \ --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": "KomeijiForce/bart-large-emojilm-e2t", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use KomeijiForce/bart-large-emojilm-e2t with Docker Model Runner:
docker model run hf.co/KomeijiForce/bart-large-emojilm-e2t
Commit ยท
200acca
1
Parent(s): 2056599
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,51 +1,60 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
-
|
| 4 |
-
|
| 5 |
-
-
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
datasets:
|
| 3 |
+
- KomeijiForce/Text2Emoji
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
metrics:
|
| 7 |
+
- bertscore
|
| 8 |
+
pipeline_tag: text2text-generation
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# EmojiLM
|
| 12 |
+
|
| 13 |
+
This is a [BART](https://huggingface.co/facebook/bart-large) model pre-trained on the [Text2Emoji](https://huggingface.co/datasets/KomeijiForce/Text2Emoji) dataset to translate emojis into texts.
|
| 14 |
+
|
| 15 |
+
For instance, "๐๐" will be translated into "I love pizza".
|
| 16 |
+
|
| 17 |
+
An example implementation for translation:
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
from transformers import BartTokenizer, BartForConditionalGeneration
|
| 21 |
+
|
| 22 |
+
def translate(sentence, **argv):
|
| 23 |
+
inputs = tokenizer(sentence, return_tensors="pt")
|
| 24 |
+
generated_ids = generator.generate(inputs["input_ids"], **argv)
|
| 25 |
+
decoded = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
| 26 |
+
return decoded
|
| 27 |
+
|
| 28 |
+
path = "KomeijiForce/bart-large-emojilm-e2t"
|
| 29 |
+
tokenizer = BartTokenizer.from_pretrained(path)
|
| 30 |
+
generator = BartForConditionalGeneration.from_pretrained(path)
|
| 31 |
+
|
| 32 |
+
sentence = "๐ฃ๐ฑ๐"
|
| 33 |
+
decoded = translate(sentence, num_beams=4, do_sample=True, max_length=100)
|
| 34 |
+
print(decoded)
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
You will probably get some output like "Sushi is my go-to comfort food."
|
| 38 |
+
|
| 39 |
+
If you find this model & dataset resource useful, please consider cite our paper:
|
| 40 |
+
|
| 41 |
+
```
|
| 42 |
+
@article{DBLP:journals/corr/abs-2311-01751,
|
| 43 |
+
author = {Letian Peng and
|
| 44 |
+
Zilong Wang and
|
| 45 |
+
Hang Liu and
|
| 46 |
+
Zihan Wang and
|
| 47 |
+
Jingbo Shang},
|
| 48 |
+
title = {EmojiLM: Modeling the New Emoji Language},
|
| 49 |
+
journal = {CoRR},
|
| 50 |
+
volume = {abs/2311.01751},
|
| 51 |
+
year = {2023},
|
| 52 |
+
url = {https://doi.org/10.48550/arXiv.2311.01751},
|
| 53 |
+
doi = {10.48550/ARXIV.2311.01751},
|
| 54 |
+
eprinttype = {arXiv},
|
| 55 |
+
eprint = {2311.01751},
|
| 56 |
+
timestamp = {Tue, 07 Nov 2023 18:17:14 +0100},
|
| 57 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-2311-01751.bib},
|
| 58 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
| 59 |
+
}
|
| 60 |
+
```
|