Sign up to save tools and stay up to date with the latest in AI
bg
bg
1

GitHub - eth-sri/language-model-arithmetic: Controlled Text Generation via Language Model Arithmetic

Dec 09, 2023 - github.com
The article discusses a comprehensive framework called model arithmetic for controlled text generation. This framework allows the combination of language models and classifiers using arithmetic formulas, enabling the generation of text biased towards or away from desired attributes. The article provides examples of how to use model arithmetic to interpolate between two differently-prompted models, integrate classifiers into model arithmetic expressions, and use custom operators for text generation. It also discusses the use of different models in a formula, speculative sampling, eager mode, and other operators.

Model arithmetic is compatible with the LM Evaluation harness and can be used to run benchmarks. The article also provides instructions on how to reproduce the results presented in the paper "Controlled Text Generation via Language Model Arithmetic". It mentions the need for API keys for the PERSPECTIVE API and OpenAI, and the availability of processed datasets for reproducing the results. The article concludes with a citation for the work.

Key takeaways:

  • The repository contains code for model arithmetic, a framework that combines language models and classifiers to control the attributes of generated text.
  • Model arithmetic allows for the combination of prompts, models, and classifiers to create new, precisely controlled language models. It also supports the integration of classifiers into model arithmetic expressions to control the formality of the output.
  • The library provides several operators that can be used in formulas, including the Union operator for adding a magic touch to the fairy tale, the TopPTopK operator for using nucleus and top-k sampling within a formula, and the Superseded operator for implementing speculative sampling directly.
  • The model arithmetic is compatible with the LM Evaluation harness and can be used to reproduce the results presented in the paper, "Controlled Text Generation via Language Model Arithmetic".
View Full Article

Comments (0)

Be the first to comment!