Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0407307

Browse files
Merge pull request avinashkranjan#2707 from Shivansh-Jain-github/gssoc2
True False Automation
2 parents 148eaea + 4d01156 commit 0407307

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

‎True False Automation/README.md‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Statement Truth Evaluation using OpenAI GPT-3
2+
3+
This repository contains a Python script that uses the OpenAI GPT-3 model to evaluate the truth or falsehood of statements in a given list. The script sends each statement as a prompt to the GPT-3 model and analyzes the model's response to determine whether the statement is considered true or false according to the model's understanding.
4+
5+
## Prerequisites
6+
7+
- Python 3.x
8+
- Install the `openai` package using the following command:
9+
10+
```bash
11+
pip install openai
12+
```
13+
14+
## Getting Started
15+
16+
1. Clone this repository to your local machine:
17+
18+
```bash
19+
git clone https://github.com/your-username/gpt3-statement-evaluation.git
20+
```
21+
22+
2. Navigate to the repository's directory:
23+
24+
```bash
25+
cd gpt3-statement-evaluation
26+
```
27+
28+
3. Set up your OpenAI API key by replacing `'YOUR_API_KEY'` with your actual OpenAI API key in the `evaluate_statements.py` file.
29+
30+
4. Run the script using your Python interpreter:
31+
32+
```bash
33+
python evaluate_statements.py
34+
```
35+
36+
## Usage
37+
38+
The `evaluate_statements.py` script in this repository demonstrates how to use the OpenAI GPT-3 model to assess the truth or falsehood of statements. It performs the following steps for each statement:
39+
40+
1. Constructs a prompt using the statement to be evaluated.
41+
2. Sends the prompt to the GPT-3 model using the OpenAI Python package.
42+
3. Extracts and prints the model's response, indicating whether the statement is considered true or false.
43+
44+
Please note that the accuracy of the truth evaluation depends on the training data and capabilities of the GPT-3 model. This approach might not always provide accurate results, especially for statements that require specific domain knowledge or factual accuracy. Always verify critical information from reliable sources.
45+
46+
## Example Output
47+
48+
```
49+
Statement: The sun rises in the west.
50+
Answer: False
51+
----------------------------
52+
Statement: Water boils at 100 degrees Celsius.
53+
Answer: False
54+
----------------------------
55+
Statement: Cats are reptiles.
56+
Answer: False
57+
----------------------------
58+
Statement: The capital of France is Paris.
59+
Answer: True
60+
----------------------------
61+
Statement: Gravity makes things fall downward.
62+
Answer: True
63+
----------------------------
64+
```
65+
66+
## Important Note
67+
68+
Ensure that you handle your API keys securely and follow OpenAI's terms of service and usage guidelines. This example provides a starting point for using the GPT-3 model to evaluate the truth or falsehood of statements.
69+
70+
For more detailed information about the OpenAI API and its capabilities, refer to the [official documentation](https://beta.openai.com/docs/).
71+

‎True False Automation/script.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import openai
2+
3+
# Set your OpenAI API key
4+
openai.api_key = 'YOUR_API_KEY'
5+
6+
# List of statements to evaluate
7+
statements = [
8+
"The sun rises in the west.",
9+
"Water boils at 100 degrees Celsius.",
10+
"Cats are reptiles.",
11+
"The capital of France is Paris.",
12+
"Gravity makes things fall downward.",
13+
]
14+
15+
# Evaluate each statement using the GPT-3 model
16+
for statement in statements:
17+
prompt = f"Check if the following statement is true or false:\nStatement: {statement}\nAnswer:"
18+
19+
response = openai.Completion.create(
20+
engine="davinci", # Use the appropriate engine
21+
prompt=prompt,
22+
max_tokens=1, # Limit the response to 1 token
23+
)
24+
25+
answer = response.choices[0].text.strip()
26+
27+
print(f"Statement: {statement}")
28+
print(f"Answer: {answer}")
29+
print("----------------------------")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /