Views
No views yet
1import requests
2import time
3
4API_URL = "https://api-inference.huggingface.co/models/kwang2049/long-coref"
5headers = {"Authorization": "Bearer ${YOUR_HUGGINGFACE_ACCESS_TOKEN}"}
6
7
8def query(payload):
9 while True:
10 response = requests.post(API_URL, headers=headers, json=payload)
11 if response.status_code == 503:
12 time.sleep(5)
13 print(response.json()["error"])
14 continue
15 elif response.status_code == 200:
16 return response.json()
17 else:
18 error_message = f"{response.status_code}: {response.json['error']}."
19 raise requests.HTTPError(error_message)
20
21
22doc = [
23 "The Half Moon is a public house and music venue in Putney, London. It is one of the city's longest running live music venues, and has hosted live music every night since 1963.",
24 "The pub is on the south side of the Lower Richmond road, in the London Borough of Wandsworth."
25]
26
27PARAGRAPH_DELIMITER = "\n\n"
28
29output = query(
30 {
31 "inputs": PARAGRAPH_DELIMITER.join(doc),
32 }
33)
34print(output)
35# {
36# 'pargraph_sentences': ...,
37# 'top_spans': ...,
38# 'antecedents': ...
39# }1# Clone the repo
2git lfs install
3git clone https://huggingface.co/kwang2049/long-coref
4cd long-coref && pip install -r requirements.txt && python local_run.py| Model | Precision | Recall | F1 | Input Length |
|---|---|---|---|---|
| AllenNLP's original implementation | 79.2 | 78.4 | 78.8 | <= 2K words |
| This modification | 78.9 | 67.0 | 72.4 | <= 40K words |
1@article{wang2023dapr,
2 title = "DAPR: A Benchmark on Document-Aware Passage Retrieval",
3 author = "Kexin Wang and Nils Reimers and Iryna Gurevych",
4 journal= "arXiv preprint arXiv:2305.13915",
5 year = "2023",
6 url = "https://arxiv.org/abs/2305.13915",
7}