-
Notifications
You must be signed in to change notification settings - Fork 129
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
[IMPLEMENTATION] magpie #740
Comments
I have tried to implement the prompting strategy of the magpie paper using distilabel's ollama integration and noticed, that the current implementation does not allow me to overwrite the chat template. I believe the TEMPLATE_OVERRIDES: dict[str, str] = {
# https://llama.meta.com/docs/model-cards-and-prompt-formats/meta-llama-3/#special-tokens-used-with-meta-llama-3
LLAMA3_8B: "<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n"
}
class OllamaMagpieLLM(OllamaLLM):
"""Magpie compatibility layer for Ollama."""
async def agenerate(
self,
input: StandardInput,
format: Literal["", "json"] = "",
# TODO: include relevant options from `Options` in `agenerate` method.
options: Options | None = None,
keep_alive: bool | None = None,
) -> GenerateOutput:
"""Override of the `OllamaLLM.agenerate` method make Ollama fill the user message.
The original implementation uses Ollama's chat endpoint instead of the generate endpoint.
This simplifies implementing multi-turn conversations, but we can't manipulate the prompt template.
"""
try:
prompt = input[0]["content"], # needs some work for multi turn support
completion: dict[str, Any] = await self._aclient.generate(
prompt=prompt
model=self.model,
template=TEMPLATE_OVERRIDES[self.model],
stream=False,
format=format,
options=options,
keep_alive=keep_alive,
)
return [completion["response"]]
except Exception as e:
self._logger.warning(
f"⚠️ Received no response using Ollama client (model: '{self.model_name}')."
f" Finish reason was: {e}"
) Note that as of writing this, the |
Hi @fpreiss, for now we have implemented |
No description provided.
The text was updated successfully, but these errors were encountered: