-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update `LLM` concept guide * Update `tasks` technical-reference * Mention `Future` as output if thread pool * Exclude docs python snippets * Add section about using `LLMPool` with `Pipeline` * Remove header from docs snippets * Finish `LLMPool` guide * Update `mkdocs-material` dep * Remove line * Add preference-dataset example * Add section about `ProcessLLM` and `LLMPool` * Remove `.git`
- Loading branch information
1 parent
00de1f1
commit 7646510
Showing
30 changed files
with
545 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from distilabel.llm import OpenAILLM | ||
from distilabel.pipeline import Pipeline | ||
from distilabel.tasks import SelfInstructTask | ||
|
||
self_instruct = SelfInstructTask( | ||
application_description="An AI application to generate tables in markdown format.", | ||
num_instructions=5, | ||
) | ||
|
||
generator = OpenAILLM(task=self_instruct) | ||
|
||
pipeline = Pipeline(generator=generator) | ||
|
||
dataset = pipeline.generate(dataset=dataset, num_generations=4, batch_size=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from distilabel.tasks import TextGenerationTask, Task | ||
from distilabel.llm import ProcessLLM, LLM, LLMPool | ||
|
||
def load_gpt_3(task: Task) -> LLM: | ||
from distilabel.llm import OpenAILLM | ||
|
||
return OpenAILLM( | ||
model="gpt-3.5-turbo", | ||
task=task, | ||
num_threads=4, | ||
) | ||
|
||
def load_gpt_4(task: Task) -> LLM: | ||
from distilabel.llm import OpenAILLM | ||
|
||
return OpenAILLM( | ||
model="gpt-4", | ||
task=task, | ||
num_threads=4, | ||
) | ||
|
||
|
||
pool = LLMPool(llms=[ | ||
ProcessLLM(task=TextGenerationTask(), load_llm_fn=load_gpt_3), | ||
ProcessLLM(task=TextGenerationTask(), load_llm_fn=load_gpt_4), | ||
]) | ||
result = pool.generate( | ||
inputs=[{"input": "Write a letter for Bob"}], num_generations=2 | ||
) | ||
pool.teardown() | ||
# >>> print(result[0][0]["parsed_output"]["generations"], end="\n\n\n\n\n\n---->") | ||
# Dear Bob, | ||
# I hope this letter finds you in good health and high spirits. I know it's been a while since we last caught up, and I wanted to take the time to connect and share a few updates. | ||
# Life has been keeping me pretty busy lately. [Provide a brief overview of what you've been up to: work, school, family, hobbies, etc.] | ||
# I've often found myself reminiscing about the good old days, like when we [include a memorable moment or shared experience with Bob]. | ||
# >>> print(result[0][1]["parsed_output"]["generations"]) | ||
# Of course, I'd be happy to draft a sample letter for you. However, I would need some additional | ||
# information including who "Bob" is, the subject matter of the letter, the tone (formal or informal), | ||
# and any specific details or points you'd like to include. Please provide some more context and I'll do my best to assist you. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from distilabel.tasks import TextGenerationTask, Task | ||
from distilabel.llm import ProcessLLM, LLM | ||
|
||
|
||
def load_gpt_4(task: Task) -> LLM: | ||
from distilabel.llm import OpenAILLM | ||
|
||
return OpenAILLM( | ||
model="gpt-4", | ||
task=task, | ||
num_threads=4, | ||
) | ||
|
||
|
||
llm = ProcessLLM(task=TextGenerationTask(), load_llm_fn=load_gpt_4) | ||
future = llm.generate( | ||
inputs=[{"input": "Write a letter for Bob"}], num_generations=1 | ||
) # (1) | ||
llm.teardown() # (2) | ||
result = future.result() | ||
# >>> print(result[0][0]["parsed_output"]["generations"]) | ||
# Dear Bob, | ||
# I hope this letter finds you in good health and high spirits. I know it's been a while since we last caught up, and I wanted to take the time to connect and share a few updates. | ||
# Life has been keeping me pretty busy lately. [Provide a brief overview of what you've been up to: work, school, family, hobbies, etc.] | ||
# I've often found myself reminiscing about the good old days, like when we [include a memorable moment or shared experience with Bob]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from distilabel.tasks import TextGenerationTask | ||
from distilabel.llm import vLLM | ||
from vllm import LLM | ||
|
||
llm = vLLM( | ||
vllm=LLM(model="argilla/notus-7b-v1"), | ||
task=TextGenerationTask(), | ||
max_new_tokens=512, | ||
temperature=0.3, | ||
prompt_format="notus", | ||
) | ||
result_vllm = llm.generate([{"input": "What's a large language model?"}]) | ||
# >>> print(result[0][0]["parsed_output"]["generations"]) | ||
# A large language model is a type of artificial intelligence (AI) system that is designed | ||
# to understand and interpret human language. It is called "large" because it uses a vast | ||
# amount of data, typically billions of words or more, to learn and make predictions about | ||
# language. Large language models are ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_generator_2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_generator_3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_labeller_2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_labeller_3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_labeller_generator_1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_labeller_generator_2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
docs/snippets/technical-reference/pipeline/pipeline_labeller_generator_3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
docs/snippets/technical-reference/pipeline/pipeline_llmpool_processllm_1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from distilabel.llm import LLM, ProcessLLM | ||
from distilabel.tasks import Task, TextGenerationTask | ||
|
||
|
||
def load_notus(task: Task) -> LLM: # (1) | ||
import os | ||
from distilabel.llm import vLLM | ||
from vllm import LLM | ||
|
||
os.environ["CUDA_VISIBLE_DEVICES"] = "0" # (2) | ||
|
||
return vLLM( | ||
vllm=LLM(model="argilla/notus-7b-v1"), | ||
task=task, | ||
max_new_tokens=512, | ||
temperature=0.7, | ||
prompt_format="notus", | ||
) | ||
|
||
|
||
llm = ProcessLLM(task=TextGenerationTask(), load_llm_fn=load_notus) |
Oops, something went wrong.