Comments (2)
@freckletonj hi!
Yes, the eos
token is handled differently by a stoppingCriteria and the generation runs in a loop until eos
is generated. You can overcome it by removing the eos_token_id
from model's config. But in that case you need another stopping criteria, for example (max_new_tokens=30), otherwise the loop will forever.
So a short snippet like this should work and the generation stops exactly after 32nd new token
# set eos tokens to None so that the generation goes on even after eos
model.config.eos_token_id = None
model.generation_config.eos_token_id = None
model.config.forced_eos_token_id = None
stop = StopAfterTokenIsGenerated(tokens['input_ids'].size(1), stop_tokens, sentinel)
output = model.generate(
**tokens,
max_new_tokens=32,
do_sample=False,
pad_token_id=tokenizer.pad_token_id,
logits_processor=[stop, ],
)
from transformers.
Ah, that makes sense thank you!
from transformers.
Related Issues (20)
- [Phi-3-mini-128k-instruct] Difference in slow and fast tokenization after adding new tokens HOT 2
- Cannot copy out of meta tensor; no data! for SwinV2ForImageClassification HOT 3
- Mismatched tensor size error when generating text with beam_search on mps
- Question about quantized model with zero3 HOT 1
- [i18n-<languageCode>] Translating docs to <languageName> HOT 1
- default max value of max_new_token HOT 5
- LLM inference with static kv-cache example gives different generations depending on the batch examples HOT 7
- Add Wav2Vec2BertProcessorWithLM HOT 1
- Issue related to dtype with F.conv1d in Whisper evaluation HOT 2
- Bug with train class method for MobileViTForSemanticSegmentation HOT 2
- Starcoder2 has +10% inference latency when flash attention 2 is enabled HOT 2
- CLIP Training Example Bug - Overfitting HOT 1
- `PreTrainedTokenizerFast._batch_encode_plus()` got an unexpected keyword argument `'split_special_tokens'` HOT 1
- Cannot save HQQ quantized model. HOT 6
- LLama-3 8B - can't match MMLU performance HOT 2
- Pure Python `PreTrainedTokenizer` is Broken HOT 1
- Construct a Marian tokenizer. Based on huggingface tokenizers HOT 2
- DDP error with load_best_model_at_end enabled
- Error while moving model to GPU `NotImplementedError: Cannot copy out of meta tensor; no data!` HOT 4
- KV cache with CPU offloading HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transformers.