Skip to content

Commit

Permalink
Merge pull request #62 from Aleph-Alpha/finalize-documentation
Browse files Browse the repository at this point in the history
Finalize documentation
  • Loading branch information
volkerstampa authored Nov 14, 2022
2 parents 000bbef + 48d1810 commit f42ef1e
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.5.0

- Introduce AsyncClient
- Reworked Readme.md to link to extended examples and Google Colab Notebooks

## 2.4.4

- Fix: ImagePrompt.from_url raises if status-code not OK
Expand Down
127 changes: 127 additions & 0 deletions aleph_alpha_client/aleph_alpha_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,22 @@ async def complete(
checkpoint: Optional[str] = None,
) -> CompletionResponse:
"""Generates completions given a prompt.
Parameters:
request (CompletionRequest, required):
Parameters for the requested completion.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
# create a prompt
prompt = Prompt("An apple a day, ")
Expand All @@ -991,6 +1007,22 @@ async def tokenize(
checkpoint: Optional[str] = None,
) -> TokenizationResponse:
"""Tokenizes the given prompt for the given model.
Parameters:
request (TokenizationRequest, required):
Parameters for the requested tokenization.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
request = TokenizationRequest(prompt="hello", token_ids=True, tokens=True)
Expand All @@ -1012,6 +1044,22 @@ async def detokenize(
checkpoint: Optional[str] = None,
) -> DetokenizationResponse:
"""Detokenizes the given prompt for the given model.
Parameters:
request (DetokenizationRequest, required):
Parameters for the requested detokenization.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
request = DetokenizationRequest(token_ids=[2, 3, 4])
Expand All @@ -1033,6 +1081,22 @@ async def embed(
checkpoint: Optional[str] = None,
) -> EmbeddingResponse:
"""Embeds a text and returns vectors that can be used for downstream tasks (e.g. semantic similarity) and models (e.g. classifiers).
Parameters:
request (EmbeddingRequest, required):
Parameters for the requested embedding.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
request = EmbeddingRequest(prompt=Prompt.from_text("This is an example."), layers=[-1], pooling=["mean"])
result = await client.embed(request, model=model_name)
Expand All @@ -1054,6 +1118,22 @@ async def semantic_embed(
) -> SemanticEmbeddingResponse:
"""Embeds a text and returns vectors that can be used for downstream tasks
(e.g. semantic similarity) and models (e.g. classifiers).
Parameters:
request (SemanticEmbeddingRequest, required):
Parameters for the requested semnatic embedding.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
# function for symmetric embedding
Expand Down Expand Up @@ -1099,6 +1179,21 @@ async def evaluate(
) -> EvaluationResponse:
"""Evaluates the model's likelihood to produce a completion given a prompt.
Parameters:
request (EvaluationRequest, required):
Parameters for the requested evaluation.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
request = EvaluationRequest(
prompt=Prompt.from_text("hello"), completion_expected="world"
Expand All @@ -1122,6 +1217,22 @@ async def qa(
checkpoint: Optional[str] = None,
) -> QaResponse:
"""Answers a question about documents.
Parameters:
request (QaRequest, required):
Parameters for the qa request.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
request = QaRequest(
query="Who likes pizza?",
Expand All @@ -1146,6 +1257,22 @@ async def summarize(
checkpoint: Optional[str] = None,
) -> SummarizationResponse:
"""Summarizes a document.
Parameters:
request (SummarizationRequest, required):
Parameters for the requested summarization.
model (string, optional, default None):
Name of model to use. A model name refers to a model architecture (number of parameters among others).
Always the latest version of model is used.
Need to set exactly one of model_name and checkpoint_name.
checkpoint (string, optional, default None):
Name of checkpoint to use. A checkpoint name refers to a language model architecture (number of parameters among others).
Need to set exactly one of model_name and checkpoint_name.
```
request = SummarizationRequest(
document=Document.from_text("Andreas likes pizza."),
Expand Down
2 changes: 1 addition & 1 deletion aleph_alpha_client/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.4.4"
__version__ = "2.5.0"

0 comments on commit f42ef1e

Please sign in to comment.