-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from backend-developers-ltd/return_hashes_from_…
…http return hashes of output files from http prompt answering
- Loading branch information
Showing
18 changed files
with
2,379 additions
and
845 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,43 @@ | ||
name: Run QA | ||
|
||
on: | ||
push: | ||
branches: [master, main] | ||
pull_request: | ||
branches: [master, main] | ||
|
||
env: | ||
PYTHON_DEFAULT_VERSION: "3.11" | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_DEFAULT_VERSION }} | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: python -m pip install --upgrade 'pdm==2.19.3' | ||
- name: Setup virtualenv | ||
run: | | ||
pdm config venv.backend venv | ||
python -m venv .venv | ||
echo "$.venv/bin" >> $GITHUB_PATH | ||
echo "VIRTUAL_ENV=${{ github.workspace }}/.venv" >> $GITHUB_ENV | ||
echo "PDM_IGNORE_SAVED_PYTHON=1" >> $GITHUB_ENV | ||
- name: Install dependencies | ||
run: pdm sync --group :all | ||
- name: Install test dependencies | ||
run: pdm sync --group test; pdm add pytest 'requests>=2.32.3,<3.0.0' | ||
# for the life of me I don't understand why pdm refuses to | ||
# install pytest in github actions | ||
- name: list | ||
run: pdm list | ||
- name: Run unit tests | ||
run: pdm run python -m pytest tests/integration_mock/ |
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
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,7 @@ | ||
[pytest] | ||
python_files = tests.py test_*.py *_tests.py | ||
filterwarnings = | ||
error | ||
default::DeprecationWarning | ||
default:Error when trying to teardown test databases | ||
addopts = -s |
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,97 @@ | ||
import argparse | ||
import dataclasses | ||
import pathlib | ||
from typing import Optional, List | ||
|
||
|
||
@dataclasses.dataclass | ||
class Config: | ||
input_files: List[pathlib.Path] | ||
output_dir: pathlib.Path | ||
model: str | ||
max_tokens: int | ||
temperature: float | ||
top_p: float | ||
dtype: str | ||
seed: Optional[int] | ||
server: Optional[bool] | ||
server_port: int | ||
mock: bool | ||
|
||
|
||
def parse_arguments() -> Config: | ||
parser = argparse.ArgumentParser( | ||
description="Generate responses for prompts using vLLM." | ||
) | ||
parser.add_argument( | ||
"input_files", | ||
nargs="+", | ||
type=pathlib.Path, | ||
help="Input files containing prompts", | ||
) | ||
parser.add_argument( | ||
"--output-dir", | ||
default="./output", | ||
type=pathlib.Path, | ||
help="Directory to save output files", | ||
) | ||
parser.add_argument( | ||
"--model", default="microsoft/Phi-3.5-mini-instruct", help="Model name or path" | ||
) | ||
parser.add_argument( | ||
"--max-tokens", | ||
type=int, | ||
default=256, | ||
help="Maximum number of tokens to generate", | ||
) | ||
parser.add_argument( | ||
"--temperature", type=float, default=0, help="Sampling temperature" | ||
) | ||
parser.add_argument( | ||
"--top-p", type=float, default=0.1, help="Top-p sampling parameter" | ||
) | ||
parser.add_argument( | ||
"--dtype", | ||
default="auto", | ||
choices=("auto", "half", "float16", "bfloat16", "float", "float32"), | ||
help=( | ||
"model dtype - setting `float32` helps with deterministic prompts in different batches" | ||
), | ||
) | ||
|
||
seed_or_server_group = parser.add_mutually_exclusive_group(required=True) | ||
seed_or_server_group.add_argument( | ||
"--seed", type=int, help="Random seed for reproducibility" | ||
) | ||
seed_or_server_group.add_argument( | ||
"--server", | ||
action="store_true", | ||
help="Spin up a temporary HTTP server to receive the seed", | ||
) | ||
|
||
parser.add_argument( | ||
"--server-port", | ||
type=int, | ||
default=8000, | ||
help="Port for temporary HTTP server", | ||
) | ||
parser.add_argument( | ||
"--mock", | ||
action="store_true", | ||
help="Don't use an actual model, generate random gibberish based on the input and the seed", | ||
) | ||
args = parser.parse_args() | ||
|
||
return Config( | ||
input_files=args.input_files, | ||
output_dir=args.output_dir, | ||
model=args.model, | ||
max_tokens=args.max_tokens, | ||
temperature=args.temperature, | ||
top_p=args.top_p, | ||
dtype=args.dtype, | ||
seed=args.seed, | ||
server=args.server, | ||
server_port=args.server_port, | ||
mock=args.mock, | ||
) |
Oops, something went wrong.