Comments (3)
Opened in #1665
from ctranslate2.
I think my question was too broad because that issue doesn't seem related to my issue. For my case, I have this working:
import ctranslate2
import sentencepiece as spm
translator = ctranslate2.Translator("../models/sugoi-v4-ja-en-ct2", device="cuda")
spsource = spm.SentencePieceProcessor("../models/sugoi-v4-ja-en-ct2/spm.ja.nopretok.model")
sptarget = spm.SentencePieceProcessor("../models/sugoi-v4-ja-en-ct2/spm.en.nopretok.model")
input_text = "日本語上手"
input_tokens = spsource.encode(input_text, out_type=str)
results = translator.translate_batch([input_tokens])
detokenized=""
for i in range(len(results)):
detokenized+=sptarget.decode(results[i].hypotheses[0])
print(detokenized)
But I want to know if it's possible to do this with ctranslate2.Generator instead.
Does ctranslate2.Translator and ctranslate2.Generator do the same thing in the backend? Is it possible pass a prompt into ctranslate2.Generator in such a way which will return the same result as ctranslate2.Translator?
from ctranslate2.
Sorry for the misunderstanding. I am not sure I can understand your purpose. As I understand, you want to run a Generator to do a translation as Translator? Actually, we don't support the model like that. Then, the backends of Generator and Translator are the same but the architecture behind in Translator is Encoder-Decoder, otherwise the architecture behind Generator is Decoder only, so you can't use the actual model to run with Generator.
from ctranslate2.
Related Issues (20)
- Support for Zephyr and other "StableLmForCausalLM" models? HOT 2
- Benchmarking Whisper on ctranslate2, llama.cpp, and bitsandbytes HOT 1
- Deploying with model and tensor parallelism HOT 3
- When building from source missing C++ libraries HOT 6
- int8 quantization not working HOT 1
- I try to pytest but it complains that "AttributeError: module 'ctranslate2' has no attribute 'get_cuda_device_count'" HOT 5
- Error when converting NMT model with ALiBi or RoPe HOT 2
- [Gemma] GELU should be approx tanh not exact HOT 2
- Asking about the return_scores during generation HOT 7
- 4.2.0 release build for python 3.9 HOT 13
- include/ctranslate2/ops/flash-attention/flash_fwd_launch_template.h(15): error: identifier "__grid_constant__" is undefined HOT 3
- `unload_model` support for `Generator` HOT 3
- No kernel image is available for execution on the device HOT 1
- Does fairseq transform align can returns the alignment result? HOT 3
- Running Llama3 like a genius (that I am not) [SOLVED]: HOT 2
- Phi-3 support HOT 9
- faster-whisper inferencing problem HOT 2
- Congrats on flash attention, now how do I run it??? HOT 3
- BENCHmarking new flash attention! HOT 10
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 ctranslate2.