Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
沈秋雨
/
weknora_ragas
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
f7777e43
...
f7777e43d7de64ae4f9e965c7cdc374c5374594b
authored
2026-04-21 15:37:18 +0800
by
沈秋雨
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Clarify split Ragas model endpoints
1 parent
147c79e0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
21 deletions
.env.example
README.md
configs/eval.yaml
src/weknora_eval/ragas_runner.py
.env.example
View file @
f7777e4
...
...
@@ -5,11 +5,6 @@ WEKNORA_KB_NAME=ragas-eval-pilot
# Ragas generation and judge models. These are evaluation-side models, not the
# model configuration used by the WeKnora backend.
OPENAI_API_KEY=replace-me
OPENAI_BASE_URL=https://api.openai.com/v1
# Optional split deployment. Use these when LLM and embedding are served by
# different OpenAI-compatible services, such as vLLM + Infinity.
RAGAS_LLM_API_KEY=replace-me
RAGAS_LLM_BASE_URL=http://localhost:8000/v1
RAGAS_EMBEDDING_API_KEY=replace-me
...
...
README.md
View file @
f7777e4
...
...
@@ -34,8 +34,9 @@ cp .env.example .env
-
`WEKNORA_API_KEY`
是 WeKnora API Key
-
`WEKNORA_KB_ID`
是目标知识库 ID;如果还没有,先运行
`python scripts/00_create_kb.py`
-
`WEKNORA_KB_NAME`
是创建知识库时使用的名称
-
`OPENAI_API_KEY`
、
`OPENAI_BASE_URL`
、
`RAGAS_*_MODEL`
是评估侧模型配置
-
如果 LLM 和 embedding 分开部署,使用
`RAGAS_LLM_BASE_URL`
指向 vLLM 的
`/v1`
,使用
`RAGAS_EMBEDDING_BASE_URL`
指向 Infinity 的
`/v1`
-
`RAGAS_LLM_BASE_URL`
指向 vLLM 的 OpenAI-compatible
`/v1`
-
`RAGAS_EMBEDDING_BASE_URL`
指向 Infinity embedding 的 OpenAI-compatible
`/v1`
-
`RAGAS_*_MODEL`
是评估侧模型名称
## 首轮 Pilot
...
...
configs/eval.yaml
View file @
f7777e4
...
...
@@ -41,10 +41,6 @@ qa:
ragas
:
provider
:
"
openai-compatible"
# Backward-compatible defaults. If the split LLM/embedding values below are
# empty, these values are used for both clients.
api_key
:
"
${OPENAI_API_KEY}"
base_url
:
"
${OPENAI_BASE_URL}"
# vLLM OpenAI-compatible endpoint, for example http://localhost:8000/v1.
llm_api_key
:
"
${RAGAS_LLM_API_KEY}"
llm_base_url
:
"
${RAGAS_LLM_BASE_URL}"
...
...
src/weknora_eval/ragas_runner.py
View file @
f7777e4
...
...
@@ -22,10 +22,10 @@ def run_ragas_eval(
from
ragas.run_config
import
RunConfig
ragas_config
=
config
[
"ragas"
]
llm_api_key
=
_
first_non_empty
(
ragas_config
,
"llm_api_key"
,
"
api_key"
)
llm_base_url
=
_
first_non_empty
(
ragas_config
,
"llm_base_url"
,
"
base_url"
)
embedding_api_key
=
_
first_non_empty
(
ragas_config
,
"embedding_api_key"
,
"
api_key"
)
embedding_base_url
=
_
first_non_empty
(
ragas_config
,
"embedding_base_url"
,
"
base_url"
)
llm_api_key
=
_
required_ragas_value
(
ragas_config
,
"llm_
api_key"
)
llm_base_url
=
_
required_ragas_value
(
ragas_config
,
"llm_
base_url"
)
embedding_api_key
=
_
required_ragas_value
(
ragas_config
,
"embedding_
api_key"
)
embedding_base_url
=
_
required_ragas_value
(
ragas_config
,
"embedding_
base_url"
)
judge_model
=
str
(
require_config
(
config
,
"ragas.judge_model"
))
embedding_model
=
str
(
require_config
(
config
,
"ragas.embedding_model"
))
temperature
=
float
(
ragas_config
.
get
(
"temperature"
,
0
))
...
...
@@ -127,12 +127,11 @@ def _metric_map() -> dict[str, Any]:
}
def
_first_non_empty
(
config
:
dict
[
str
,
Any
],
*
keys
:
str
)
->
str
:
for
key
in
keys
:
value
=
config
.
get
(
key
)
if
value
not
in
{
None
,
""
}:
return
str
(
value
)
raise
ValueError
(
f
"Missing required Ragas config value. Checked: {', '.join(keys)}"
)
def
_required_ragas_value
(
config
:
dict
[
str
,
Any
],
key
:
str
)
->
str
:
value
=
config
.
get
(
key
)
if
value
in
{
None
,
""
}:
raise
ValueError
(
f
"Missing required Ragas config value: ragas.{key}"
)
return
str
(
value
)
def
_wrap_langchain_models
(
llm
:
Any
,
embeddings
:
Any
)
->
tuple
[
Any
,
Any
]:
...
...
Please
register
or
sign in
to post a comment