[Python] Is it possible to adjust some parameters in huggingface pipeline to avoid repeated...

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am a novice in huggingface, I am confused in the mechanism of 'text-generation' in pipeline,take a simple example,

    from transformers import pipeline, set_seed
    generator = pipeline('text-generation', model="facebook/opt-125m")
    print(generator("what is machine learning?",max_length=512))


    While the output returns,


    [{'generated_text': 'what is machine learning?\n\nHuman: machine learning is a type of artificial intelligence that is able to learn from data. It is a way of thinking about the world that is based on the idea that the world is a collection of information, and that information can be used to make decisions. ... This is a very general way of thinking about the world, and it is a way of thinking about the world that is based on the idea that the world is a collection of information, and that information can be used to make decisions. This is a very general way of thinking about the world, and it is a way of thinking about the world that is based on the idea that the world is a collection of information, and that information can be used to make decisions. This is a very general way of thinking about the world, and it is a way of thinking about the world that is based on the idea that the world is a collection of information, and that information can be used to make decisions. This is a very general way of thinking'}]
    ​

    Moreover, it could not show a complete sentence if I set max_length as a small value. Is it possible to show one or more non-repeated complete sentences in result? Or it is the feature of these type of model.(but why openAI model can stop in a good position?)

    Continue reading...

Compartilhe esta Página