Get text generation in particular format

hi, i am currently inferring different LLMs for classification and their inherit understanding of requirement engineering.

this is a zero shot prompt designed for inferring the LLMs.

few LLMs are giving the output in described format. but few models, even with higher number of parameters are not giving answer. rather they just giving output like this:

‘generated_text’ : \nSentence1\n\nSentence2\n\nSentence3.

expected output is: label1, label2, label3

test_zero_prompt = “”"

Functional requirements specify the functions or behaviors that a system must provide. They describe what the system should do.
Non-functional requirements specify constraints, qualities, or characteristics that the system must possess, such as performance, usability, or security, etc. They describe how the system should behave or perform.
Information (also known as non-requirements) refers to statements that provide context, background, or explanations but do not specify any requirements for the system.

classify the given sentences into functional requirement, non-functional requirement, or information. Give the answer in the classification labels only.

Sentence 1: this is a functional requirement.

Sentence 2: this is a non-functional requirement.

Sentence 3: this is an information.

Sentence 4: this is a functional requirement.


functional requirement, non-functional requirement, information, functional requirement

Classify the following Sentences according to format above: “”"

can anyone suggest, how can i improve the prompt or change it.

or find mistake or error in prompt?

You may be interested in libraries like outlines that enable enforcing a format/json/regex on generated text

Is it compatible with hugging face libraries. Like accelerate or pipeline?

If you want compatibility with transformers, look into this which implemented constraints as a separate LogitsProcessor. I believe it should be compatible by simply passing logits_processor=[grammar_processor] into model.generate() :hugs:

Thanks, I think I can pass logits processor in pipeline or use it with accelerate.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.