Model Card for Model ID
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
4# Set a manual seed for reproducibility
5torch.manual_seed(0)
6
7# Load the model with specific configurations
8model = AutoModelForCausalLM.from_pretrained(
9 "AlanYky/phi-3.5_tweets_instruct",
10 device_map="cuda",
11 torch_dtype="auto",
12 trust_remote_code=True
13)
14model.to("cuda")
15
16# Load the tokenizer
17tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3.5-mini-instruct")
18
19# Define a function to generate tweets
20def generate_tweet(instruction, pipe, generation_args):
21 """
22 Generate a tweet response based on an instruction.
23 """
24 # Define the message structure
25 messages = [
26 {
27 "role": "user",
28 "content": instruction
29 }
30 ]
31
32 # Generate the tweet response
33 output = pipe(messages, **generation_args)
34
35 # Extract and return the generated tweet text
36 return output[0]['generated_text']
37
38# Set up the pipeline for text generation
39pipe = pipeline(
40 "text-generation",
41 model=model,
42 tokenizer=tokenizer,
43)
44
45# Define generation arguments for tweet creation
46generation_args = {
47 "max_new_tokens": 70,
48 "return_full_text": False,
49 "temperature": 0.4,
50 "top_k": 50,
51 "top_p": 0.9,
52 "repetition_penalty": 1.2,
53 "do_sample": True,
54}
55
56# Specify an instruction for tweet generation
57instruction = "Generate a tweet about Donald Trump is the 2024 US President."
58generated_tweet = generate_tweet(instruction, pipe, generation_args)
59print(generated_tweet)
60
Model Details
Model Description
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
- Developed by: [More Information Needed]
- Funded by [optional]: [More Information Needed]
- Shared by [optional]: [More Information Needed]
- Model type: [More Information Needed]
- Language(s) (NLP): [More Information Needed]
- License: [More Information Needed]
- Finetuned from model [optional]: [More Information Needed]
Model Sources [optional]
- Repository: [More Information Needed]
- Paper [optional]: [More Information Needed]
- Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the
Machine Learning Impact calculator presented in
Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]