Skip to content

Commit

Permalink
[Feature] Several enhancements (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaotongxiao authored Aug 1, 2023
1 parent c00179d commit 8b163bd
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 4 deletions.
69 changes: 69 additions & 0 deletions .pre-commit-config-zh-cn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
exclude: |
(?x)^(
tests/data/|
opencompass/models/internal/|
opencompass/utils/internal/|
configs/
)
repos:
- repo: https://gitee.com/openmmlab/mirrors-flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://gitee.com/openmmlab/mirrors-isort
rev: 5.11.5
hooks:
- id: isort
- repo: https://gitee.com/openmmlab/mirrors-yapf
rev: v0.32.0
hooks:
- id: yapf
- repo: https://gitee.com/openmmlab/mirrors-codespell
rev: v2.2.1
hooks:
- id: codespell
- repo: https://gitee.com/openmmlab/mirrors-pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
exclude: |
(?x)^(
dicts/|
projects/.*?/dicts/
)
- id: check-yaml
- id: end-of-file-fixer
exclude: |
(?x)^(
dicts/|
projects/.*?/dicts/
)
- id: requirements-txt-fixer
- id: double-quote-string-fixer
- id: check-merge-conflict
- id: fix-encoding-pragma
args: ["--remove"]
- id: mixed-line-ending
args: ["--fix=lf"]
- id: mixed-line-ending
args: ["--fix=lf"]
- repo: https://gitee.com/openmmlab/mirrors-mdformat
rev: 0.7.9
hooks:
- id: mdformat
args: ["--number", "--table-width", "200"]
additional_dependencies:
- mdformat-openmmlab
- mdformat_frontmatter
- linkify-it-py
- repo: https://gitee.com/openmmlab/mirrors-docformatter
rev: v1.3.1
hooks:
- id: docformatter
args: ["--in-place", "--wrap-descriptions", "79"]
# - repo: https://github.com/open-mmlab/pre-commit-hooks
# rev: v0.2.0 # Use the ref you want to point at
# hooks:
# - id: check-algo-readme
# - id: check-copyright
# args: ["mmocr", "tests", "tools"] # these directories will be checked
4 changes: 0 additions & 4 deletions opencompass/openicl/icl_inferencer/icl_clp_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import itertools
import os
from functools import partial
from typing import List, Optional

import torch.nn.functional as F
Expand Down Expand Up @@ -127,9 +126,6 @@ def inference(self,
# in case tokenizer returns list for single token
choice_ids = list(itertools.chain(*choice_ids))

get_token_len = partial(
self.model.get_token_len, # COPYBARA_INTERNAL # noqa
eos=False) # COPYBARA_INTERNAL # noqa
get_token_len = self.model.get_token_len

# prepare in context for each example and control the length
Expand Down
19 changes: 19 additions & 0 deletions opencompass/utils/lark.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import json
from typing import Dict, List, Optional, Union

Expand Down Expand Up @@ -37,3 +38,21 @@ def post(self,
}
}
requests.post(self.url, data=json.dumps(msg))


def parse_args():
parser = argparse.ArgumentParser(description='Lark bot reporter')
parser.add_argument('url', help='Lark bot url')
parser.add_argument('content', type=str, help='Content')
parser.add_argument('--title', type=str, help='Title', default=None)
args = parser.parse_args()
return args


if __name__ == '__main__':
args = parse_args()
lark = LarkReporter(args.url)
if args.title:
lark.post(args.content, args.title)
else:
lark.post(args.content)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
absl-py
accelerate>=0.19.0
boto3
colossalai
Expand All @@ -14,6 +15,7 @@ openai
pandas<2.0.0
rank_bm25==0.2.2
requests==2.28.1
rouge_score
scikit_learn==1.2.1
sentence_transformers==2.2.2
tabulate
Expand Down

0 comments on commit 8b163bd

Please sign in to comment.