()
| 47 | |
| 48 | |
| 49 | def main(): |
| 50 | |
| 51 | for quant_config, calib_config in quant_and_calib_configs: |
| 52 | # The built-in end-to-end quantization is triggered according to the passed quant_config. |
| 53 | llm = LLM(model="TinyLlama/TinyLlama-1.1B-Chat-v1.0", |
| 54 | quant_config=quant_config, |
| 55 | calib_config=calib_config) |
| 56 | |
| 57 | # Sample prompts. |
| 58 | prompts = [ |
| 59 | "Hello, my name is", |
| 60 | "The capital of France is", |
| 61 | "The future of AI is", |
| 62 | ] |
| 63 | |
| 64 | # Create a sampling params. |
| 65 | sampling_params = SamplingParams(temperature=0.8, top_p=0.95) |
| 66 | |
| 67 | for output in llm.generate(prompts, sampling_params): |
| 68 | print( |
| 69 | f"Prompt: {output.prompt!r}, Generated text: {output.outputs[0].text!r}" |
| 70 | ) |
| 71 | llm.shutdown() |
| 72 | |
| 73 | # Got output like |
| 74 | # Prompt: 'Hello, my name is', Generated text: 'Jane Smith. I am a resident of the city. Can you tell me more about the public services provided in the area?' |
| 75 | # Prompt: 'The capital of France is', Generated text: 'located in Paris, France. The population of Paris, France, is estimated to be 2 million. France is home to many famous artists, including Picasso' |
| 76 | # Prompt: 'The future of AI is', Generated text: 'an open and collaborative project. The project is an ongoing effort, and we invite participation from members of the community.\n\nOur community is' |
| 77 | |
| 78 | |
| 79 | if __name__ == '__main__': |
no test coverage detected