generate_qa

Function

Passes the title and body content through QAGenerationConfig and truncates the content based on the value of max_tokens of QAGenerationConfig.

If the QA pair returned by an LLM does not meet the format and quantity requirements, the QA pair will be skipped. The following lists QA examples that meet the requirements:

Q1: How can I query the stopped trains at Chengdu Railway Station?
Reference paragraph:'Query method: Homepage of China Railway 12306. Query process: Step 1: Go to the home page of China Railway 12306 and click [Station Screen]. Step 2: Select Chengdu East Railway Station from the drop-down list box in the upper left corner. Step 3: Enter a train number in the search box.
Q2: Which level does Sichuan Government raise the flood disaster prevention and response level to?
Reference paragraph: Sichuan Government raised the flood disaster prevention and response level to level-3 from level-4.
Q3: On July 14, what kind of weather warning was released by Sichuan Provincial Meteorological Bureau?
Reference paragraph: At 15:30 on July 14, the Sichuan Provincial Meteorological Bureau released a rainstorm warning at the blue level.

Prototype

def generate_qa(llm_config)

Parameters

Parameter

Data Type

Required/Optional

Description

llm_config

LLMParameterConfig

Optional

Parameters for calling an LLM. Change the default value of temperature to 0.5 and that of top_p to 0.95. For details about other parameters, see LLMParameterConfig.

Return Value

Data Type

Description

Dict

Generated QA pair list in the following format:

{"How long does it take from Chengdu to Chongqing? : One hour by high-speed railway", ...}