Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
neubig committed Nov 10, 2023
0 parents commit 4ab63ec
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Continuous Integration

Check warning on line 1 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / lint-yaml

1:1 [document-start] missing document start "---"
on: # yamllint disable-line rule:truthy

Check warning on line 2 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / lint-yaml

2:5 [comments] too few spaces before comment
push:
branches:
- main
pull_request:
branches: ["**"]

jobs:
python-ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python 3
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install ruff
run: pip install ruff
- name: Run ruff
run: ruff --check .
python-mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python 3
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: mypy
uses: pre-commit/action@v3.0.0
with:
extra_args: mypy --all-files
lint-requirements-txt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: requirements-txt-fixer --all-files
lint-markdown:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: markdownlint-cli2 --all-files
lint-yaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: yamllint --all-files
lint-json:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: check-json --all-files
lint-shell-script:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: shellcheck --all-files
lint-trailing-whitespace:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: trailing-whitespace --all-files
lint-eof-newline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: lint
uses: pre-commit/action@v3.0.0
with:
extra_args: end-of-file-fixer --all-files
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release workflow

Check warning on line 1 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / lint-yaml

1:1 [document-start] missing document start "---"

on:

Check warning on line 3 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / lint-yaml

3:1 [truthy] truthy value should be one of [false, true]
push:
tags:
- "v[0123456789].*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: build
run: |
python -m pip install --upgrade build hatch
python -m hatch version "${GITHUB_REF_NAME}"
python -m build
- name: publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__
build
llments.egg-info
.vscode
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:

Check warning on line 1 in .pre-commit-config.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

1:1 [document-start] missing document start "---"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.6.1'
hooks:
- id: mypy

Check failure on line 10 in .pre-commit-config.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

10:8 [hyphens] too many spaces after hyphen

Check failure on line 10 in .pre-commit-config.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

10:5 [indentation] wrong indentation: expected 6 but found 4
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.10.0
hooks:
- id: markdownlint-cli2
- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
hooks:
- id: yamllint
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: check-json
- id: requirements-txt-fixer
- id: trailing-whitespace
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) Carnegie Mellon University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# llments

## Development Information

```bash
pip install .
pre-commit install
```
Empty file added llments/__init__.py
Empty file.
Empty file added llments/eval/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions llments/eval/eval.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import abc
import dataclasses


@abc.abstract
class PairwiseEvaluator:
"""A class that defines an evaluation function, assessing a hypothesized string."""

@abc.abstractmethod
def evaluate(self, hyp: str, ref: str) -> float:
"""Returns an evaluation score between 0 and 1 for two strings.
Args:
hyp: The hypothesized string (e.g. a system output).
ref: The reference string (e.g. a gold-standard output).
"""
...


@dataclasses.dataclass
class EvaluatorMetadata:
...


@abc.abstract
class GeneralEvaluator:
"""A class that defines an evaluation function, assessing a hypothesized string."""

@abc.abstractmethod
def evaluate(self, hyp: str, ref: EvaluatorMetadata) -> float:
"""Returns an evaluation score between 0 and 1 for two strings.
Args:
hyp: The hypothesized string (e.g. a system output).
ref: The reference string (e.g. a gold-standard output).
"""
...
Empty file added llments/lm/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions llments/lm/lm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

class LanguageModel:


15 changes: 15 additions & 0 deletions llments/lm/loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


from llments.lm.lm import LanguageModel


def load_from_spec_file(spec_file: str) -> LanguageModel:
"""Load a language model from a specification file.
Args:
spec_file: The path to the specification file.
Returns:
A language model.
"""
raise NotImplementedError
4 changes: 4 additions & 0 deletions llments/lm/loader_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

def test_load_from_spec_file():
"""Test that load_from_specification_file() loads a language model."""
raise NotImplementedError
1 change: 1 addition & 0 deletions llments/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "0.0.0a1"
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "llments"
authors = [
{name = "Graham Neubig", email = "neubig@gmail.com"},
]
description = "llments"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "MIT"}
classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = []
dynamic = ["version"]

[project.optional-dependencies]
dev = [
"pre-commit"
]

[tool.setuptools.dynamic]
version = {attr = "llments.version.VERSION"}

0 comments on commit 4ab63ec

Please sign in to comment.