Instructions to use bluejwu/conservative-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bluejwu/conservative-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bluejwu/conservative-gpt2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("bluejwu/conservative-gpt2") model = AutoModelForCausalLM.from_pretrained("bluejwu/conservative-gpt2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use bluejwu/conservative-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bluejwu/conservative-gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bluejwu/conservative-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/bluejwu/conservative-gpt2
- SGLang
How to use bluejwu/conservative-gpt2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "bluejwu/conservative-gpt2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bluejwu/conservative-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "bluejwu/conservative-gpt2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bluejwu/conservative-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use bluejwu/conservative-gpt2 with Docker Model Runner:
docker model run hf.co/bluejwu/conservative-gpt2
conservative-gpt2
conservative-gpt2 is OpenAI's gpt2 fine tuned on news articles from conservative leaning news outlets (FOX, The American Conservative and The Washington Times) from the liberal-and-conservative-news dataset.
Final Eval Loss: 2.722
Example Usage
from transformers import GPT2TokenizerFast, GPT2LMHeadModel
tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
model = GPT2LMHeadModel.from_pretrained("bluejwu/conservative-gpt2")
prompt = "Once upon a time, Alice"
encoded_input = tokenizer(prompt, return_tensors="pt")
output_sequences = model.generate(
input_ids=encoded_input["input_ids"],
max_length=400,
temperature=0.7,
top_k=55,
top_p=0.95,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
repetition_penalty=1.015,
no_repeat_ngram_size=6,
)
text = tokenizer.decode(output_sequences[0], skip_special_tokens=True)
print(text)
Example Output
Prompt: "Once upon a time, Alice"
Once upon a time, Alice was still working at the library, but she was not in school. She was a child of immigrants from the South. Her father and mother were born in the United States, and they lived in Chicago, Illinois, for many years.
Her parents arrived in the U.S. in the mid-1970s after her mother fled a country she loved. Her mother had an American Indian background, and she came to the U.S. to study medicine.
Alice is an immigrant from Mexico, which means she has lived here for more than 20 years. But she has no idea what's going on there. "I don't know what to say," she said. "If you don't know what to do, you're going to die here."
Her mother has been staying in Texas for nearly two years, and she is still being treated for mental health issues. She went to Texas to get a job, but it was not easy. "It's hard," she said.
The situation has worsened since the COVID pandemic, when more than 7 million people were left homeless and left without health care. She said the federal government has been struggling to provide shelter and food, and she fears it will not be able to fulfill its promise to send more than 2 million migrants to the border.
Alice said she has no idea what to do, and she feels that she has to go back to Mexico. "I'm still a stranger," she said. "My family has been here a long time, and I don't know what to expect. I'm not sure what to expect right now."]
The American dream is finally returning: The Supreme Court's decision to strike down affirmative action
Fox News Flash top headlines are here. Check out what's clicking on Foxnews.com.
The Supreme Court ruled Friday that colleges and universities must provide equal
Prompt: "Trump is"
Trump is the strongest candidate in the race.
"I think Donald Trump is the strongest candidate in this race," said a Trump campaign official, who spoke on condition of anonymity to discuss internal deliberations.
Trump is expected to announce his 2024 bid on Tuesday.
The Trump campaign is not disclosing the names of those running for president or vice president.
Trump, who is the commanding front-runner in the GOP nomination race, has a long history of defending his presidential candidacy. He has repeatedly attacked Democrats over their refusal to accept evidence that he lost the 2020 election to President Biden.
In June, Trump said he would pardon then-President Barack Obama if elected president. The former president later said he did not believe Obama was responsible for the November 2020 election.
Trump has said that he would appoint judges who would overturn the results of the election if elected president.
Trump's legal team has argued that he is being unfairly targeted because he is a Republican and that the election was stolen.
The Associated Press and The Associated Press contributed to this report.]
'Swing' lawmaker pushes back against 'woke' censorship in California: 'I would love to be the one to stop it'
Fox News contributor and progressive activist Jack Posobiec joins 'Fox & Friends First' to discuss the state of the political landscape in California and why he believes that censorship is necessary to protect the rights of LGBTQ+ youth.
A California lawmaker on the House Judiciary Committee is pushing back against "woke" censorship in California, arguing that the state's censorship of speech is "ineffective" in the country.
Rep. Chris Smith, R-San Francisco, introduced a bill in the state Assembly on Wednesday that would require that California's Department of Education (DOE) "ensure that all public school students are adequately informed of censorship" and "ensure that all school districts have a clear and objective policy on censorship."
License
This software is licensed under the MIT-0 license. The intent is to effectively place this work in the public domain.
MIT No Attribution
Copyright 2024 Jonathan Wu
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Downloads last month
- -