Skip to content

Commit

Permalink
Merge pull request #53 from BatsResearch/update-huggingfacedocqa
Browse files Browse the repository at this point in the history
Updating Docs & DocQA Launch
  • Loading branch information
dotpyu authored Nov 6, 2023
2 parents 8fb4bce + 9acd0f5 commit 8feda8e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
7 changes: 6 additions & 1 deletion alfred/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(
if self.model_type:
self.model_type = model_type.lower()
assert self.model_type in [
"huggingface", "huggingfacevlm",
"huggingface", "huggingfacevlm", ""
"onnx", "tensorrt",
"flexgen", "vllm",
"openai", "anthropic",
Expand Down Expand Up @@ -152,6 +152,11 @@ def __init__(
self.model = HuggingFaceCLIPModel(self.model,
local_path=local_path,
**kwargs)
elif self.model_type == "huggingfacedocument":
from alfred.fm.huggingfacedocument import HuggingFaceDocumentModel
self.model = HuggingFaceDocumentModel(self.model,
local_path=local_path,
**kwargs)
elif self.model_type == "anthropic":
from alfred.fm.anthropic import AnthropicModel
self.model = AnthropicModel(self.model, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion alfred/fm/huggingfacedocument.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import re
from typing import Optional, List, Tuple
from typing import Optional, List, Tuple, Any

import torch
from PIL import Image
Expand All @@ -26,6 +26,7 @@ def __init__(
self,
model_string: str,
local_path: Optional[str] = None,
**kwargs: Any,
):
"""
Constructor for HuggingFaceDocumentModel
Expand Down
7 changes: 6 additions & 1 deletion alfred/run_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def __init__(
self.model = model
self.model_type = model_type.lower()
assert self.model_type in [
"huggingface", "huggingfacevlm", "onnx", "tensorrt", "openai", "anthropic",
"huggingface", "huggingfacevlm", "huggingfacedocument",
"onnx", "tensorrt", "openai", "anthropic",
"flexgen", "vllm",
"cohere", "ai21", "torch", "dummy"
], f"Invalid model type: {self.model_type}"
Expand All @@ -56,6 +57,10 @@ def __init__(
from alfred.fm.huggingfacevlm import HuggingFaceCLIPModel
self.model = HuggingFaceCLIPModel(self.model,
**kwargs)
elif self.model_type == "huggingfacedocument":
from alfred.fm.huggingfacedocument import HuggingFaceDocumentModel
self.model = HuggingFaceDocumentModel(self.model,
**kwargs)
elif self.model_type == "anthropic":
from alfred.fm.anthropic import AnthropicModel
self.model = AnthropicModel(self.model, **kwargs)
Expand Down
16 changes: 8 additions & 8 deletions docs/alfred/client/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Client:

### Client().__call__

[Show source in client.py:274](../../../alfred/client/client.py#L274)
[Show source in client.py:279](../../../alfred/client/client.py#L279)

__call__() function to run the model on the queries.
Equivalent to run() function.
Expand Down Expand Up @@ -76,7 +76,7 @@ def __call__(

### Client().calibrate

[Show source in client.py:289](../../../alfred/client/client.py#L289)
[Show source in client.py:294](../../../alfred/client/client.py#L294)

calibrate are used to calibrate foundation models contextually given the template.
A voter class may be passed to calibrate the model with a specific voter.
Expand Down Expand Up @@ -121,7 +121,7 @@ def calibrate(

### Client().chat

[Show source in client.py:391](../../../alfred/client/client.py#L391)
[Show source in client.py:396](../../../alfred/client/client.py#L396)

Chat with the model APIs.
Currently, Alfred supports Chat APIs from Anthropic and OpenAI
Expand All @@ -140,7 +140,7 @@ def chat(self, log_save_path: Optional[str] = None, **kwargs: Any):

### Client().encode

[Show source in client.py:365](../../../alfred/client/client.py#L365)
[Show source in client.py:370](../../../alfred/client/client.py#L370)

embed() function to embed the queries.

Expand All @@ -163,7 +163,7 @@ def encode(

### Client().generate

[Show source in client.py:233](../../../alfred/client/client.py#L233)
[Show source in client.py:238](../../../alfred/client/client.py#L238)

Wrapper function to generate the response(s) from the model. (For completion)

Expand Down Expand Up @@ -192,7 +192,7 @@ def generate(

### Client().remote_run

[Show source in client.py:211](../../../alfred/client/client.py#L211)
[Show source in client.py:216](../../../alfred/client/client.py#L216)

Wrapper function for running the model on the queries thru a gRPC Server.

Expand All @@ -219,7 +219,7 @@ def remote_run(

### Client().run

[Show source in client.py:191](../../../alfred/client/client.py#L191)
[Show source in client.py:196](../../../alfred/client/client.py#L196)

Run the model on the queries.

Expand All @@ -246,7 +246,7 @@ def run(

### Client().score

[Show source in client.py:250](../../../alfred/client/client.py#L250)
[Show source in client.py:255](../../../alfred/client/client.py#L255)

Wrapper function to score the response(s) from the model. (For ranking)

Expand Down
4 changes: 3 additions & 1 deletion docs/alfred/fm/huggingfacedocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Currently supports:

```python
class HuggingFaceDocumentModel(LocalAccessFoundationModel):
def __init__(self, model_string: str, local_path: Optional[str] = None):
def __init__(
self, model_string: str, local_path: Optional[str] = None, **kwargs: Any
):
...
```

Expand Down
2 changes: 1 addition & 1 deletion docs/alfred/run_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ModelServer:

## start_server

[Show source in run_server.py:99](../../alfred/run_server.py#L99)
[Show source in run_server.py:104](../../alfred/run_server.py#L104)

Wrapper function to start gRPC Server.

Expand Down

0 comments on commit 8feda8e

Please sign in to comment.