C#学习:构建一个更真实的基于LLM的简历评估系统

360影视 日韩动漫 2025-06-01 08:43 2

摘要:昨天的Demo以txt文件为例进行说明,并且评估标准写死了,跟真实的简历评估系统差别太大了。今天分享的是经过改进后更加真实的基于LLM的简历评估系统。

昨天的Demo以txt文件为例进行说明,并且评估标准写死了,跟真实的简历评估系统差别太大了。今天分享的是经过改进后更加真实的基于LLM的简历评估系统。

使用AI生成了5份不同的简历,如下所示:

程序员A:

image-20250529150723475

程序员B:

image-20250529150852726

程序员C:

image-20250529150944801

程序员D:

image-20250529151025846

程序员E:

image-20250529151113896

输入要求:

shared["requirements"] = """
- 具备前端开发能力
- 使用过Vue
""";

效果:

image-20250529151320596

更改要求:

shared["requirements"] = """
- 具备后端开发能力
- 熟悉go语言
""";
image-20250529151840530

全部代码已上传至GitHub,地址:https://github.com/Ming-jiayou/PocketFlowSharp/tree/main/PocketFlowSharpSamples.Console/Real_Resume_Qualification_Demo

image-20250529152111462

项目简介:使用 C# 读取和提取 PDF 中的文本和其他内容(PDFBox 的移植)

修改Utils类,增加读取PDF内容功能:

public static string ExtractTextFromPdf(string pdfPath)
{
StringBuilder text = new StringBuilder;

using (PdfDocument document = PdfDocument.Open(pdfPath))
{
foreach (Page page in document.GetPages)
{
text.AppendLine(page.Text);
}
}

return text.ToString;
}

效果如下所示:

image-20250529152359085

可以将要求存入共享内存,然后通过$插值字符串,插入到提示词中即可:

string prompt = $@"
评估以下简历并确定候选人是否符合职位的要求。
资格标准:
{requirements}

简历内容:
{content}

请以YAML格式返回您的评估:
```yaml
candidate_name: [候选人姓名]
qualifies: [true/false]
reasons:
- [资格认定/不认定的第一个原因]
- [第二个原因(如果适用)]
```
";

运行时就会变成这样:

image-20250529152810159 public staticstring ModelName { get; set; }
publicstaticstring EndPoint { get; set; }
publicstaticstring ApiKey { get; set; }

public static stringCallLLM(string prompt)
{
ApiKeyCredential apiKeyCredential = new ApiKeyCredential(ApiKey);

OpenAIClientOptions openAIClientOptions = new OpenAIClientOptions;
openAIClientOptions.Endpoint = new Uri(EndPoint);

ChatClient client = new(model: ModelName, apiKeyCredential, openAIClientOptions);

ChatCompletion completion = client.CompleteChat(prompt);

return completion.Content[0].Text;
}

以上就是通过这个Demo可以学习到的一些内容。

来源:opendotnet

相关推荐