Giter VIP home page Giter VIP logo

Comments (3)

minhthuc2502 avatar minhthuc2502 commented on June 1, 2024

Opened in #1665

from ctranslate2.

Weroxig avatar Weroxig commented on June 1, 2024

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.

minhthuc2502 avatar minhthuc2502 commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.