在某些情况下,您可能希望与LLM共享自定义样本头。例如,您可能不愿意与LLM共享潜在的敏感信息。或者,您可能只是想提供更好的示例给LLM,以提高回答的质量。您可以通过如下方式将自定义头传递给LLM来实现这一点:

from pandasai import SmartDataframe

import pandas as pd



# head df

head_df = pd.DataFrame({

    "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],

    "gdp": [19294482071552, 2891615567872, 2411255037952, 3435817336832, 1745433788416, 1181205135360, 1607402389504, 1490967855104, 4380756541440, 14631844184064],

    "happiness_index": [6.94, 7.16, 6.66, 7.07, 6.38, 6.4, 7.23, 7.22, 5.87, 5.12]

})



df = SmartDataframe("data/country_gdp.csv", config={

    "custom_head": head_df

})

这样做将使LLM使用head_df作为自定义头部,而不是数据框的前5行。