MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / main

Function main

examples/llm-api/_tensorrt_engine/llm_quantization.py:49–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47
48
49def 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
79if __name__ == '__main__':

Callers 1

Calls 4

SamplingParamsClass · 0.90
LLMClass · 0.50
generateMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected