-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
252 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# OpenAssitant Inference | ||
|
||
Preliminary implementation of the inference engine for OpenAssistant. | ||
|
||
## Development (you'll need multiple terminals) | ||
|
||
Run a redis container: | ||
|
||
```bash | ||
docker run --rm -it -p 6379:6379 redis | ||
``` | ||
|
||
Run the inference server: | ||
|
||
```bash | ||
cd server | ||
pip install -r requirements.txt | ||
uvicorn main:app --reload | ||
``` | ||
|
||
Run one (or more) workers: | ||
|
||
```bash | ||
cd worker | ||
pip install -r requirements.txt | ||
python __main__.py | ||
``` | ||
|
||
Run the client: | ||
|
||
```bash | ||
cd text-client | ||
pip install -r requirements.txt | ||
python __main__.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,14 @@ | ||
# OpenAssistant Inference Server | ||
|
||
Workers communicate with the `/work` endpoint. They provide their configuration | ||
and if a task is available, the server returns it. The server also returns the | ||
key of a Redis list where the worker should push the results. | ||
|
||
Clients communicate first with the `/complete` endpoint to place a request for | ||
prompt completion. The server returns a unique ID for the request. The client | ||
then polls the `/stream` endpoint with the ID to check if the request has been | ||
assigned to a worker. Once it is assigned, the response will be a SSE event | ||
source. | ||
|
||
Notably, `/complete` could be proxied via a frontend, while `/stream` can be | ||
accessed directly by the client, since the unique ID provides enough security. |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
fastapi[all] | ||
loguru | ||
pydantic | ||
redis | ||
sse-starlette |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
loguru | ||
redis | ||
requests | ||
torch | ||
transformers | ||
typer |
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,18 @@ | ||
import pydantic | ||
|
||
|
||
class WorkerConfig(pydantic.BaseModel): | ||
model_name: str = "distilgpt2" | ||
|
||
|
||
class WorkRequest(pydantic.BaseModel): | ||
stream_queue_id: str | ||
prompt: str = pydantic.Field(..., repr=False) | ||
model_name: str = "distilgpt2" | ||
max_length: int = 100 | ||
seed: int = 42 | ||
|
||
|
||
class WorkResponsePacket(pydantic.BaseModel): | ||
token: str | None = None | ||
is_end: bool = False |