Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 31 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4f5e686
Setting up GitHub Classroom Feedback
github-classroom[bot] Apr 14, 2023
ad94fdd
Add assignment deadline url
github-classroom[bot] Apr 14, 2023
c41d165
Names
Burnytoast Apr 14, 2023
247ca57
PortionOfProposal
Burnytoast Apr 14, 2023
c0a2f3a
Punctuation
Burnytoast Apr 14, 2023
c5eea95
docs: Add names to report.md
ningerson2002 Apr 21, 2023
7a3aacd
docs: Complete project summary in report.md
ningerson2002 Apr 21, 2023
5cc57eb
Adding Political Stance
Burnytoast Apr 22, 2023
9957c0e
Update PoliticianBeliefDoc.txt
Burnytoast Apr 22, 2023
a590fbd
need to pull
MilesF25 Apr 22, 2023
29def80
Merge branch 'main' of github.com:CMPSC-310-AI-Spring2023/project-Bur…
MilesF25 Apr 22, 2023
a6ab94e
Merge branch 'main' of github.com:CMPSC-310-AI-Spring2023/project-Bur…
MilesF25 Apr 22, 2023
4c44a21
Merge branch 'main' of github.com:CMPSC-310-AI-Spring2023/project-Bur…
MilesF25 Apr 23, 2023
0aebc6c
added
MilesF25 Apr 23, 2023
9870073
added some more speeches
MilesF25 Apr 25, 2023
5998a1c
Implement text generation
ningerson2002 Apr 26, 2023
f9cb739
Fix build error
ningerson2002 Apr 26, 2023
b042f13
trying to pull
MilesF25 Apr 26, 2023
392db56
merge
MilesF25 Apr 26, 2023
e660027
Created using Colaboratory
Burnytoast May 2, 2023
f32763b
fix: Update API key in text_generator.py
ningerson2002 May 2, 2023
dc23268
Remove unused YourCode.py from repository
ningerson2002 May 2, 2023
ed31949
Initialize politician/ folder
ningerson2002 May 2, 2023
fc63180
added to report
MilesF25 May 2, 2023
ebb7f85
Merge branch 'main' of github.com:CMPSC-310-AI-Spring2023/project-Bur…
MilesF25 May 2, 2023
d5135cb
feat: Implement text generation with OpenAI API in text_generator.py
ningerson2002 May 2, 2023
24c7e64
Remove API key to prevent leaks in text_generator.py
ningerson2002 May 2, 2023
9834628
docs: Add information on how to run and install the speech generator
ningerson2002 May 4, 2023
4382755
docs: Add sample output to report.md
ningerson2002 May 4, 2023
3c579f6
docs: Write about experimental results for text generation in report.md
ningerson2002 May 4, 2023
21a6c17
Filling In Answers
Burnytoast May 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,433 changes: 9,433 additions & 0 deletions PoliticianStableDiffusion.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-24ddc0f5d75046c5622901739e7c5dd533143b0c8e959d652212380cedb1ea36.svg)](https://classroom.github.com/a/n7swNMZG)
# Final Project: AI Application

## Deadlines
Expand Down
7 changes: 7 additions & 0 deletions politician/speech.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
My fellow citizens, I stand before you today as your newly elected representative. I am honoured and humbled by the trust you have placed in me, and I promise to work hard on your behalf.

In these uncertain times, it is more important than ever that we stand together and support one another. I will do everything in my power to make sure that your voices are heard in government.

My vision for the future is one where we all work together for the common good. I believe that we can achieve great things if we put our differences aside and focus on what we have in common.

I am committed to making your lives better, and I promise to always put your interests first. Thank you for your support, and I look forward to serving you in the years to come.
34 changes: 34 additions & 0 deletions src/PoliticianBeliefDoc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
I believe that gay married couples should be able to defend their marijuana plants with lethal force. I believe that corporate pharmacies charging appalling rates of life saving medication is theft and a crime of the highest caliber and is a massive breach of ethics. I think that humans are the virus, and the solution to solving the environmental crisis is cutting out the middle man: eliminate humanity in its entirety. Equal rights for all. Gay lives matter. Black lives matter. Police organization and training should be revised as to cater to the needs of the people, without an abuse of power. Knowledge is a powerful tool that all should have access too; a lack of understanding is what drives hate, division and misunderstanding. Taking the time to understand our fellow man is what gives us the edge to move forward.

This politician will be closer to a "far left libertarian". He will be a firm believer in natural selction is a good policy, and that people should be left to their own devices to a degree.

FDR and JFK:

ÒMy fellow Americans,
Today that prophecy is in the process of being fulfilled. The massed, angered forces of common humanity are on the march. They are going forwardÉ they came to the reluctant conclusion that the "jig was up"; he could see the shadow of the long arm of justice.Ó
But he and his Fascist gang will be brought to book, and punished for their crimes against humanity. No criminal will be allowed to escape by the expedient of "resignation."
So our terms to Italy are still the same as our terms to Germany and Japan --"unconditional surrender." With their cordial cooperation, we are establishing and maintaining security and order -- we are dissolving the organizations which have kept them under Fascist tyranny -- we are providing them with the necessities of life until the time comes when they can fully provide for themselves.

We have started to make good on that promise.
I am sorry if I step on the toes of those Americans who, playing party politics at home, call that kind of foreign policy "crazy altruism" and "starry-eyed dreaming."

We shall not settle for less than total victory. That is the determination of every American on the fighting fronts. That must be, and will be, the determination of every American here at home.

"Liberty, Equality and Fraternity"

Two thousand years ago the proudest boast was "civis Romanus sum." Today, in the world of freedom, the proudest boast is "Ich bin ein Berliner."



The key to faking out the parents is the clammy hands. It's a good non-specific symptom. A lot of people will tell you that a phony fever is a dead lock, but if you get a nervous mother, you could land in the doctor's office.
That's worse than school. What you do is: you fake a stomach cramp, and when you're bent over, moaning and wailing, you lick your palms. It's a little childish and stupid, but then, so is high school.
I did have a test today. That wasn't bullshit. It's on European Socialism. I mean, really, what's the point? I'm not European, I don't plan on being European, so who gives a crap if they're socialist?
They could be fascist anarchists - that still wouldn't change the fact that I don't own a car. Not that I condone fascism, or any -ism, for that matter. Isms, in my opinion, are not good. A person should not believe in an -ism - he should believe in himself.
I quote John Lennon: "I don't believe in Beatles - I just believe in me." A good point there. Of course, he was the Walrus. I could be the Walrus - I'd still have to bum rides off of people.

To that world assembly of sovereign states, the United Nations, our last best hope in an age where the instruments of war have far outpaced the instruments of peace, we renew our pledge of support — to prevent it from becoming merely a forum for invective — to strengthen its shield of the new and the weak — and to enlarge the area in which its writ may run.

Finally, to those nations who would make themselves our adversary, we offer not a pledge but a request: that both sides begin anew the quest for peace, before the dark powers of destruction unleashed by science engulf all humanity in planned or accidental self-destruction.


In the long history of the world, only a few generations have been granted the role of defending freedom in its hour of maximum danger. I do not shrink from this responsibility — I welcome it. I do not believe that any of us would exchange places with any other people or any other generation. The energy, the faith, the devotion which we bring to this endeavour will light our country and all who serve it — and the glow from that fire can truly light the world.
3 changes: 0 additions & 3 deletions src/YourCode.py

This file was deleted.

29 changes: 29 additions & 0 deletions src/text_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import openai

openai.organization = 'org-tiQjuNLO4GEneutRBVq6wVx6'
openai.api_key = '' # Add your API key here

def generate_text(prompt, model, temperature=0.5, max_tokens=712):
response = openai.Completion.create(
engine=model,
prompt=prompt,
temperature=temperature,
max_tokens=max_tokens,
n=1,
stop=None,
timeout=10
)

if response.choices:
return response.choices[0].text.strip()
else:
return ""

prompt = "Congratulations on your election victory! As a newly elected politician, you have a unique opportunity to make a difference in the lives of your constituents. Write a speech to inspire them and outline your vision for the future."
model = "text-davinci-002"

generated_text = generate_text(prompt, model, temperature=0.5, max_tokens=712)
print(generated_text)

with open('politician/speech.txt', 'w') as f:
f.write(generated_text)
9 changes: 7 additions & 2 deletions writing/proposal.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Project Proposal

## TODO: Add your name(s)
## TODO: Andrew Briercheck, Miles Franck, Nic Ingerson

## Proposed Application

TODO: Describe your proposed application, including its motivation with at least three references. Indicate what you might use to implement it (algorithms, libraries, tools, etc.). If you require any hardware components, list them here as well.
We are proposing developing an AI that would a viable political candidate. We will be implimenting and improving code from the movie generation project, but using that to generate a viable set of ideals for out "candidate" and will output those responses in a short speech. We will then use snipits of these ideas to generate a "portrait" of our politician using stable diffusion and we will have him "deliver" his speech, using eleven labs.

References:
https://beta.elevenlabs.io/
https://stablediffusionweb.com/

41 changes: 31 additions & 10 deletions writing/report.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
# Project Report

## TODO: Add your name(s)
## : Andrew Briercheck, Miles Franck, and Nic Ingerson

## Project Summary

TODO
For our final project, we are developing a synthetic politician. To do this, we are creating a text generator; taking
speeches from previous American presidents to create a new one. Then, we are going to attempt to do some voice synthesis
to read the speech.

## Motivation

TODO
This felt like an enjoyable extention from the previous projects we pursued. Developing a "personality" of sorts seemed like a natural direction to take natural language processing in: seeing what the computer would be able to develop in a sense of "personality" we can understand.

## Background

TODO
To develop a sense of "personality" and "beliefs" for this project, we sat down in GFC and put together a document full of "beliefs" we wanted to be reflected in our "speech". After fleshing out a number of beliefs, we then fed it presential speeches to use as a reference, and hoped that it would regurgitate something in a similar vein.

## Project Implementation Details

TODO: include instructions on how to set up and run your project
To run the speech generator:

1. Make sure that python is installed on your system. To check this, run the following command: `python --version`. Otherwise, check the [documentation website](https://www.python.org) to find instructions on how to install python on your system.
2. Next, you need to clone the repository from GitHub. You can do this by opening your command line interface, navigating to the directory where you want to clone the repository, and typing `git clone [email protected]:CMPSC-310-AI-Spring2023/project-Burnytoast.git`
3. Then, you need to install the `openai` package with the following command: `pip install openai`.
4. After installing the `openai` package, navigate to the directory where you cloned the repository. Then, you need to navigate to the `src` directory and open the `text_generator.py` file. Edit the line of code with the comment `Add OpenAI API Key` to contain your OpenAI API key within the `''`.
5. Finally, run the `text_generator.py` file by running the following command: `python3[/python/py] text_generator.py`

To run PoliticanStableDiffusion.ipynb:
1. Open in Colab
2. Ensure the program is utilizing GPU (runtime > change runtime type > GPU)
3. Run cell by cell, in order.

## Testing Details

TODO
The StableDiffusion was somewhat uncooperative: we found that relocating the files, transpoting the ipynb into VsCode did not work. After relocating to Colab, the program was cooperating some. The code was then trimmed an altered to fit our needs. The output has been 12 images that vary slightly on the contents: they tend to generally be pictures of generic politicians, sometimes with LGBTQ+ flags in the background, and facial features entering the uncanny valley.

## Sample Output

TODO
```cmd
My fellow citizens, I stand before you today as your newly elected representative. I am honoured and humbled by the trust you have placed in me, and I promise to work hard on your behalf.

In these uncertain times, it is more important than ever that we stand together and support one another. I will do everything in my power to make sure that your voices are heard in government.

My vision for the future is one where we all work together for the common good. I believe that we can achieve great things if we put our differences aside and focus on what we have in common.

I am committed to making your lives better, and I promise to always put your interests first. Thank you for your support, and I look forward to serving you in the years to come.
```

## Experimental Results

TODO
When attempting to write the text generation program, we ran into issues with how the program reads certain files and how that affects some variables. In order to overcome these issues, we decided to utilize the OpenAI API library to generate speeches based on a prompt; allowing for a more user-customizable politician in the end.

## Ethical Implications

TODO
Using text generation technology to impersonate politicians and spread false information can be highly unethical and damaging to individuals and society. It is important to approach the use of this technology with caution and to make sure we understand the potential consequences before using it

## Team Working Strategy (if worked in a team)

TODO
Our team worked together on all aspects of the project. We searched for speeches to use in training, collaborated on coding tasks, and solved problems together.