KAG icon indicating copy to clipboard operation
KAG copied to clipboard

约束kag严格按照添加的schema进行知识抽取

Open AlexanderGU316 opened this issue 7 months ago • 6 comments

怎样确保kag中大模型的知识抽取结果严格贴合用户构建的schema,避免生成无关的"Others"类别? How to ensure that the knowledge extraction results of the LLM in Kag strictly conform to the schema constructed by the user, and avoid generating irrelevant "Others" categories?

求解答 Many thanks.

AlexanderGU316 avatar May 26 '25 08:05 AlexanderGU316

prompt and postprocessor

thundax-lyp avatar May 26 '25 08:05 thundax-lyp

怎样确保kag中大模型的知识抽取结果严格贴合用户构建的schema,避免生成无关的"Others"类别? How to ensure that the knowledge extraction results of the LLM in Kag strictly conform to the schema constructed by the user, and avoid generating irrelevant "Others" categories?

求解答 Many thanks.

You can use schema_constraint_extractor to Constrain the output of LLM by post-filtering with the help of customized schema.

caszkgui avatar Jun 02 '25 01:06 caszkgui

请问indexer导入的数据是怎么和设置的schema对应呢,导入的结构化数据和schema有什么必须要遵守的要求吗,我导入的结构化数据大部分都没有和schema建立很好的映射,这是为什么

kuibawansui avatar Sep 12 '25 03:09 kuibawansui

请问indexer导入的数据是怎么和设置的schema对应呢,导入的结构化数据和schema有什么必须要遵守的要求吗,我导入的结构化数据大部分都没有和schema建立很好的映射,这是为什么

过程能具体点吗?或者上个代码/数据看看

thundax-lyp avatar Sep 12 '25 04:09 thundax-lyp

AviationAccident(航空责任事故): EntityType properties: accidentId(事故ID): Text index: Text constraint: Unique accidentName(事故名称): Text index: TextAndVector accidentType(事故类型): Text index: Text occurrenceTime(发生时间): Date occurrenceLocation(发生地点): GeographicLocation severityLevel(严重等级): Text index: Text Accident(事故)-> AviationAccident: properties: eventNumber(事件编号): Text index: Text location(地点): GeographicLocation involvedAircraft(涉及航空器): Text index: Text casualties(人员伤亡): Text index: TextAndVector economicLoss(经济损失): Number eventLevel(事件等级): Text index: Text

        index: Text
    rootCause(根本原因): Text
        index: TextAndVector

AccidentPotential(事故隐患)-> AviationAccident: properties: potentialNumber(隐患编号): Text index: Text discoveryTime(发现时间): Date discoverer(发现人): Text index: Text potentialDescription(隐患描述): Text index: TextAndVector

    rectificationStatus(整改状态): Text
        index: Text
    potentialType(隐患类型): Text
        index: Text
    possibleConsequences(可能后果): Text
        index: TextAndVector
    monitoringMeasures(监控措施): Text
        index: TextAndVector这是我设置的schema的一部分,然后下面是我在网上找的数据

"acn_num_ACN": "1299693", "Time_Date": "201510", "Time.1_Local Time Of Day": "1201-1800", "Place_Locale Reference": "ZZZ.Airport", "Place.1_State Reference": "US", "Place.2_Relative Position.Angle.Radial": "", "Place.3_Relative Position.Distance.Nautical Miles": "", "Place.4_Altitude.AGL.Single Value": "0.0", "Place.5_Altitude.MSL.Single Value": "", "Environment_Flight Conditions": "VMC", "Environment.1_Weather Elements / Visibility": "", "Environment.2_Work Environment Factor": "", "Environment.3_Light": "Daylight", "Environment.4_Ceiling": "", "Environment.5_RVR.Single Value": "", "Aircraft 1_ATC / Advisory": "Tower ZZZ", "Aircraft 1.1_Aircraft Operator": "Air Carrier", "Aircraft 1.2_Make Model Name": "Regional Jet 700 ER/LR (CRJ700)", "Aircraft 1.3_Aircraft Zone": "", "Aircraft 1.4_Crew Size": "2.0", "Aircraft 1.5_Operating Under FAR Part": "Part 121", "Aircraft 1.6_Flight Plan": "IFR", "Aircraft 1.7_Mission": "Training", "Aircraft 1.8_Nav In Use": "", "Aircraft 1.9_Flight Phase": "Landing", "Aircraft 1.10_Route In Use": "", "Aircraft 1.11_Airspace": "", "Aircraft 1.12_Maintenance Status.Maintenance Deferred": "N", "Aircraft 1.13_Maintenance Status.Records Complete": "", "Aircraft 1.14_Maintenance Status.Released For Service": "Y", "Aircraft 1.15_Maintenance Status.Required / Correct Doc On Board": "", "Aircraft 1.16_Maintenance Status.Maintenance Type": "", "Aircraft 1.17_Maintenance Status.Maintenance Items Involved": "", "Aircraft 1.18_Cabin Lighting": "", "Aircraft 1.19_Number Of Seats.Number": "", "Aircraft 1.20_Passengers On Board.Number": "", "Aircraft 1.21_Crew Size Flight Attendant.Number Of Crew": "", "Aircraft 1.22_Airspace Authorization Provider (UAS)": "", "Aircraft 1.23_Operating Under Waivers / Exemptions / Authorizations (UAS)": "", "Aircraft 1.24_Waivers / Exemptions / Authorizations (UAS)": "", "Aircraft 1.25_Airworthiness Certification (UAS)": "", "Aircraft 1.26_Weight Category (UAS)": "", "Aircraft 1.27_Configuration (UAS)": "", "Aircraft 1.28_Flight Operated As (UAS)": "", "Aircraft 1.29_Flight Operated with Visual Observer (UAS)": "", "Aircraft 1.30_Control Mode (UAS)": "", "Aircraft 1.31_Flying In / Near / Over (UAS)": "", "Aircraft 1.32_Passenger Capable (UAS)": "", "Aircraft 1.33_Type (UAS)": "", "Aircraft 1.34_Number of UAS Being Controlled (UAS)": "", "Component_Aircraft Component": "Throttle/Power Lever", "Component.1_Manufacturer": "", "Component.2_Aircraft Reference": "X", "Component.3_Problem": "", "Aircraft 2_ATC / Advisory": "", "Aircraft 2.1_Aircraft Operator": "", "Aircraft 2.2_Make Model Name": "", "Aircraft 2.4_Crew Size": "", "Aircraft 2.5_Operating Under FAR Part": "", "Aircraft 2.6_Flight Plan": "", "Aircraft 2.7_Mission": "", "Aircraft 2.8_Nav In Use": "", "Aircraft 2.9_Flight Phase": "", "Aircraft 2.10_Route In Use": "", "Aircraft 2.11_Airspace": "", "Aircraft 2.12_Maintenance Status.Maintenance Deferred": "", "Aircraft 2.14_Maintenance Status.Released For Service": "", "Aircraft 2.16_Maintenance Status.Maintenance Type": "", "Aircraft 2.17_Maintenance Status.Maintenance Items Involved": "", "Aircraft 2.23_Operating Under Waivers / Exemptions / Authorizations (UAS)": "", "Aircraft 2.24_Waivers / Exemptions / Authorizations (UAS)": "", "Aircraft 2.26_Weight Category (UAS)": "", "Aircraft 2.27_Configuration (UAS)": "", "Aircraft 2.28_Flight Operated As (UAS)": "", "Aircraft 2.31_Flying In / Near / Over (UAS)": "", "Aircraft 2.34_Number of UAS Being Controlled (UAS)": "", "Person 1_Location Of Person": "Aircraft X", "Person 1.1_Location In Aircraft": "Flight Deck", "Person 1.2_Reporter Organization": "Air Carrier", "Person 1.3_Function": "First Officer; Pilot Flying", "Person 1.4_Qualification": "Flight Crew Air Transport Pilot (ATP)", "Person 1.5_Experience": "", "Person 1.6_Cabin Activity": "", "Person 1.7_Human Factors": "Confusion", "Person 1.8_Communication Breakdown": "", "Person 1.9_UAS Communication Breakdown": "", "Person 1.10_ASRS Report Number.Accession Number": "1299693", "Person 2_Location Of Person": "Aircraft X", "Person 2.1_Location In Aircraft": "Flight Deck", "Person 2.2_Reporter Organization": "Air Carrier", "Person 2.3_Function": "Check Pilot; Captain", "Person 2.4_Qualification": "Flight Crew Air Transport Pilot (ATP)", "Person 2.5_Experience": "", "Person 2.6_Cabin Activity": "", "Person 2.7_Human Factors": "Confusion; Situational Awareness", "Person 2.8_Communication Breakdown": "", "Person 2.9_UAS Communication Breakdown": "", "Person 2.10_ASRS Report Number.Accession Number": "1299694.0", "Events_Anomaly": "Aircraft Equipment Problem Critical; Deviation / Discrepancy - Procedural Published Material / Policy", "Events.1_Miss Distance": "", "Events.2_Were Passengers Involved In Event": "N", "Events.3_Detector": "Person Flight Crew", "Events.4_When Detected": "Other On Landing Rollout", "Events.5_Result": "Flight Crew Overcame Equipment Problem", "Assessments_Contributing Factors / Situations": "Human Factors", "Assessments.1_Primary Problem": "Human Factors", "Report 1_Narrative": "We were on approach to landing Runway 27. I was pilot flying. The approach was normal; in the flare I brought the thrust levers to idle at the appropriate time. The left thrust lever stopped at idle and the right continued slightly. When I went to deploy reverse thrust; the left reverser deployed and the right thrust lever went back a little bit more. The Captain took control of the airplane when only the left reverser deployed. After we were pulled off the runway; I saw the right engine was in shutdown and the engine was spooling down. We stopped on the parallel taxiway and restarted the engine before taxiing back to the gate.", "Report 1.1_Callback": "", "Report 2_Narrative": "First Officer (FO) was the Pilot Flying and I was the PM giving instruction. Approaching Runway 27 everything looked really good; FO was doing a good job keeping airspeed and keeping the aircraft on glideslope. Touchdown was firm and on centerline and well within our standards. I was guarding the flight controls with my feet on the rudder pedals and hand on the yoke. My right hand was down low on the lower pedestal just in case I needed to take over and add power. After main wheels touchdown FO brought the nose wheel down nice and gentle. On the roll out; FO deployed thrust reversers with only the left deploying. I looked down at the switches and both reversers where armed. Rolling down the FO told me there was a split on the power levers and it was then that I realized the right engine was shut down. I took over the controls and taxied off the runway. I never saw the FO pull the [shut-off] trigger and I always saw his hand on top of the power levers. I really do not know how the right engine shut down. I really cannot say what the cause of this was; since Standard Operations Procedures (SOP) was followed. FO or I never pulled the trigger to shut down the engine. FO and I retraced our steps and could not come up with an explanation on what could have caused the right engine to shut down while on the rollout.", "Report 2.1_Callback": "Reporter stated the First Officer was in training and transitioning from Turboprops to their CRJ-700 aircraft. The aircraft and FO were performing just fine when the right engine suddenly shutdown. He has thought over and over again about the sequence of steps they had accomplished prior to the engine event and cannot find any reason for the shutdown except for an inadvertent contact with the shut-off trigger handle (switch) on the lower aft side of the engine throttle lever. All the more frustrating because the First Officer had performed very well and neither he; nor the FO could remember ever touching the shut-off trigger. Since the right engine restarted without any problems and no EICAS fault messages appeared; the possible movement of the right engine shut-off trigger seems to be the only plausible explanation.", "Report 1.2_Synopsis": "A First Officer and Check Pilot reported a sudden; unexplained shutdown of the right engine on a CRJ-700 aircraft during the landing rollout on a training flight. The Check Pilot noted he never saw the FO pull the right engine shut-off trigger and only observed the First Officer's hand on top of the power levers.这是个json文件的内容,我想知道这个文件和我设置的schema之间能形成很好的映射吗?KAG结构化内容的导入的机理是什么,我知道是直接映射,但是怎么映射我不知道,我在那里可以了解到具体的底层原理,这是在哪个文件里的

kuibawansui avatar Sep 13 '25 08:09 kuibawansui

就是schema设置和数据导入之间具体的对应关系在哪些文件里能找到,用indexer一次导入很多数据,那些数据怎么跟schema匹配呢

kuibawansui avatar Sep 13 '25 08:09 kuibawansui