Read-only mirror of https://github.com/epfl-dlab/GCD — EPFL Data Science & AI Lab (dlab). Issues & pull requests at the source.
  • Python 98.8%
  • Shell 1.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-03-07 10:21:17 +01:00
assets 1. centralised logging level control 2023-11-05 14:45:42 +01:00
configs update prompter to make it accept the input dp dict 2023-11-05 14:45:53 +01:00
docs update prompter to make it accept the input dp dict 2023-11-05 14:45:53 +01:00
scripts Initial commit 2023-09-08 20:10:50 +02:00
src add GFServerPoolRuntime 2023-11-21 16:21:12 +01:00
tests docs(src/models): add symbolic link solution for windows 2023-10-11 18:51:09 +02:00
.gitignore Initial commit 2023-09-08 20:10:50 +02:00
.pre-commit-config.yaml style: mark some outdated file with prefix _legacy for clarity 2023-09-24 21:57:03 +02:00
LICENSE Initial commit 2023-09-08 20:10:50 +02:00
README.md update link to dlab/transformers-CFG in readme 2025-03-07 10:21:17 +01:00
requirements.txt Rename pip_requirements.txt to requirements.txt 2023-09-24 23:42:32 +02:00
run_CP.sh docs(src/models): add symbolic link solution for windows 2023-10-11 18:51:09 +02:00
run_ED.sh docs(src/models): add symbolic link solution for windows 2023-10-11 18:51:09 +02:00
run_IE.sh docs(src/models): add symbolic link solution for windows 2023-10-11 18:51:09 +02:00
run_inference.py 1. centralised logging level control 2023-11-05 14:45:42 +01:00
run_process_predictions.py 1. centralised logging level control 2023-11-05 14:45:42 +01:00
try_IE_hf_cfgcd_grammars.patch add GFServerPoolRuntime 2023-11-21 16:21:12 +01:00

Python 3.9 MIT License arXiv

Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning


🌟 New Implementation Compatible with HuggingFace Transformers

We provide an implementation of GCD that is compatible with the popular Transformers library!

This new package, Transformers-CFG, extends the capabilities of our Grammar-Constrained Decoding (GCD) approach by integrating seamlessly with the Transformers library. It offers:

  • Easy Integration: Quickly combine the power of GCD with any model listed in the transformers library with just few lines of code!
  • Enhanced Performance: Leverage the GCD technique for more efficient and accurate generation.
  • Friendly Interface: Implemented with the EBNF grammar interface, making it accessible for both beginners and experts.

Get started with Transformers-CFG here.


1. The Overview of GCD

2. Environment Setup

With the repository cloned, we recommend creating a new conda virtual environment:

conda create -n GCD python=3.9
conda activate GCD

Install the required packages:

pip install -r requirements.txt

Experiments

Citation

This repository contains the code for the models and experiments in Grammar-Constrained Decoding for Structured NLP Tasks without Finetuning

@inproceedings{geng-etal-2023-grammar,
	title        = {Grammar-Constrained Decoding for Structured {NLP} Tasks without Finetuning},
	author       = {Geng, Saibo  and Josifoski, Martin  and Peyrard, Maxime  and West, Robert},
	year         = 2023,
	month        = dec,
	booktitle    = {Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing},
	publisher    = {Association for Computational Linguistics},
	address      = {Singapore},
	url          = {https://aclanthology.org/2023.emnlp-main.674},
	editor       = {Bouamor, Houda  and Pino, Juan  and Bali, Kalika}
}

Please consider citing our work, if you found the provided resources useful.

License

This project is licensed under the terms of the MIT license.