Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Evals] Add retrieval completion fn and example #656

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comment
  • Loading branch information
andrew-openai committed Apr 12, 2023
commit 37fd680b528a41c67e35a7706dbbeed74e73f8c0
3 changes: 1 addition & 2 deletions evals/completion_fns/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ def __call__(self, prompt: Union[str, list[dict]], **kwargs: Any) -> RetrievalCo
].text.values
)

# Ensure it is in string format
prompt = ChatCompletionPrompt(prompt).to_formatted_prompt()

retrieval_prompt = [{"role": "system", "content": self.retrieval_template + topk}] + prompt

answer = self.completion_fn_instance(prompt=retrieval_prompt, **kwargs).get_completions()[0]
record_sampling(prompt=retrieval_prompt, sampled=answer)
return RetrievalCompletionResult(answer)