Update README.md
Browse files
README.md
CHANGED
@@ -67,29 +67,45 @@ pip install -e ".[vllm]"
|
|
67 |
|
68 |
Quickstart with Python:
|
69 |
```python
|
70 |
-
from flow_judge
|
71 |
-
from flow_judge.
|
72 |
-
from flow_judge.metrics import RESPONSE_CORRECTNESS_BINARY
|
73 |
from IPython.display import Markdown, display
|
74 |
|
75 |
-
#
|
76 |
-
model =
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
# Initialize the judge
|
79 |
-
|
80 |
-
metric=
|
81 |
model=model
|
82 |
)
|
83 |
|
84 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
eval_input = EvalInput(
|
86 |
-
inputs=[
|
87 |
-
|
|
|
|
|
|
|
88 |
)
|
89 |
|
90 |
-
#
|
91 |
-
result =
|
92 |
-
|
|
|
|
|
93 |
```
|
94 |
|
95 |
Discover more at our repository [https://github.com/flowaicom/flow-judge](https://github.com/flowaicom/flow-judge)
|
|
|
67 |
|
68 |
Quickstart with Python:
|
69 |
```python
|
70 |
+
from flow_judge import Vllm, Llamafile, Hf, EvalInput, FlowJudge
|
71 |
+
from flow_judge.metrics import RESPONSE_FAITHFULNESS_5POINT
|
|
|
72 |
from IPython.display import Markdown, display
|
73 |
|
74 |
+
# If you are running on an Ampere GPU or newer, create a model using VLLM
|
75 |
+
model = Vllm(quantization=True)
|
76 |
+
|
77 |
+
# If you have other applications open taking up VRAM, you can use less VRAM by setting gpu_memory_utilization to a lower value.
|
78 |
+
# model = Vllm(gpu_memory_utilization=0.70)
|
79 |
+
|
80 |
+
# Or create a model using Llamafile if not running an Nvidia GPU & running a Silicon MacOS for example
|
81 |
+
# model = Llamafile()
|
82 |
|
83 |
# Initialize the judge
|
84 |
+
faithfulness_judge = FlowJudge(
|
85 |
+
metric=RESPONSE_FAITHFULNESS_5POINT,
|
86 |
model=model
|
87 |
)
|
88 |
|
89 |
+
# Sample to evaluate
|
90 |
+
query = ...
|
91 |
+
context = ...
|
92 |
+
response = ...
|
93 |
+
|
94 |
+
# Create an EvalInput
|
95 |
+
# We want to evaluate the response to the customer issue based on the context and the user instructions
|
96 |
eval_input = EvalInput(
|
97 |
+
inputs=[
|
98 |
+
{"query": query},
|
99 |
+
{"context": context},
|
100 |
+
],
|
101 |
+
output={"response": response},
|
102 |
)
|
103 |
|
104 |
+
# Run the evaluation
|
105 |
+
result = faithfulness_judge.evaluate(eval_input, save_results=False)
|
106 |
+
|
107 |
+
# Display the result
|
108 |
+
display(Markdown(f"__Feedback:__\n{result.feedback}\n\n__Score:__\n{result.score}"))
|
109 |
```
|
110 |
|
111 |
Discover more at our repository [https://github.com/flowaicom/flow-judge](https://github.com/flowaicom/flow-judge)
|