# Self-Refine: Iterative Refinement with Self-Feedback
_With Self-Refine, LLMs can generate feedback on their work, use it to improve the output, and repeat this process._

**Table of Contents**
- [Updates](#updates)
- [Setup](#setup)
- [Getting Started with Acronym Generation](#getting-started-with-acronym-generation)
- [Dialogue Response Generation](#dialogue-response-generation)
- [Code Readability Improvement](#code-readability-improvement)
- [Commongen](#commongen)
- [GSM-8k](#gsm-8k)
- [Yelp](#yelp)
- [PIE](#pie)
- [General setup](#general-setup)
- [Citation](#citation)
## Updates
- **Nov 2023**: Added [visual self-refine examples](docs/visual_self_refine_examples/) and [colabs](colabs/Visual-Self-Refine-GPT4V.ipynb). Use GPT4-V to write tikz code for diagrams, and improve them iteratively.
Stokes' Theorem Example
Unicorn Example
## Setup
* We use [prompt-lib](https://github.com/reasoning-machines/prompt-lib) for querying LLMs. You can install `prompt-lib` by running the following commands:
```sh
git clone https://github.com/reasoning-machines/prompt-lib
pip install prompt-lib/
```
Depending on your default settings, you may want to use the following to set a PYTHONPATH:
```sh
export PYTHONPATH=".:../:.:src:../:../../:.:prompt-lib"
```
## Getting Started with Acronym Generation
```sh
python -u src/acronym/run.py "Using language models of code for few-shot commonsense"
```
* Since we sample with temperature 0.7, you'll get different results each time you run the above command.
```swift
0 INIT> Using language models of code for few-shot commonsense
0 GEN> CLoCK
0 SCORES> * Ease of pronunciation: CLoCK is pronounced "clah-k". This is easy acronym to pronounce. 4/5
* Ease of spelling: CLoCK is easy to spell. 5/5
* Relation to title: CLoCK stands for "Code Language Models of Commonsense Knowledge" which is related to the title. 5/5
* Positive connotation: CLoCK is a positive acronym. It implies accuracy and efficiency. 5/5
* Well-known: CLoCK is not a well-known acronym. 2/5
* Total score: 21/25
1 GEN> CMNSC
1 SCORES> * Ease of pronunciation: CMNSC is pronounced "see-min-es-see". This is a difficult acronym to pronounce. 1/5
* Ease of spelling: CMNSC is difficult to spell. 1/5
* Relation to title: CMNSC stands for "Commonsense" which is related to the title. 4/5
* Positive connotation: CMNSC is a neutral acronym. 3/5
* Well-known: CMNSC is not a well-known acronym. 1/5
* Total score: 10/25
2 GEN> COMMIT
2 SCORES> * Ease of pronunciation: COMMIT is pronounced "com-mit". This is an easy acronym to pronounce. 4/5
* Ease of spelling: COMMIT is easy to spell. 5/5
* Relation to title: COMMIT stands for "Commonsense Model of Code for Intuitive Training" which is related to the title. 5/5
* Positive connotation: COMMIT is a positive acronym. It implies commitment and dedication. 5/5
* Well-known: COMMIT is not a well-known acronym. 2/5
* Total score: 21/25
```
## Dialogue Response Generation
```sh
PYTHONPATH="." python -u src/responsegen/run.py --output