01-ai/yi-6b-chat 🔢📝 → 📝

▶️ 26.1K runs 📅 Nov 2023 ⚙️ Cog 0.8.6 🔗 GitHub ⚖️ License
code-generation question-answering text-generation

About

The Yi series models are large language models trained from scratch by developers at 01.AI.

Example Output

Prompt:

"Write a script to download the images for the top 10 posts of all time from /r/pics using the PRAW library"

Output

Certainly! Below is a Python script that uses the praw (Python Reddit API Wrapper) library to fetch the top 10 posts with images from the /r/pics subreddit. Please replace API_KEY and SUBREDDIT with your own API key and subdomain respectively before running this code:

import praw
from tqdm import tqdm  # For progress bars

def get_top_posts(subreddit, limit=10):
   """Fetches the latest 'limit' number of submissions from a reddit
      subscription or search query.
   """
   client = praw.Reddit('your-api-key')
   search_result = client.get_submissions(subreddit='YourSubredditNameHere', sort='new', limit=limit)
   return [submission.url for submission in search_result]

if __name__ == "__main__":
   API_KEY = '' # Replace with your actual api key
   SUBREDDIT = r'/r/pics' # Replace with your actual subdomain
   images = []
   for post in tqdm(get_top_posts(SUBREDDIT))[:10]:
       try:
           image = praw.models.linkpreview.LinkPreview(post['data']['preview'])
           images.append({
               'title': image.title,
               'permalink': post['data']['permalink'],
               'thumbnail': image.thumbnail_src,
               'source': f'{image.host}{image.display_sources[0]}'})
       except KeyError as e:
           print(f'
{e} - Skipping Post {post["id"]}')
   with open('/path/to/output.json', 'w') as outfile:
       json.dump([{'imgUrl': img['source'], 'altText': img['title']} for img in images], outfile)

This script will output an array of dictionaries containing information about each image, including its source URL, title, and thumbnail preview. The file will be saved as JSON format at /path/to/output.json. You can adjust the limit parameter if you want more than ten results returned. Remember to change YOUR_API_KEY and YOUR_SUBDOMAIN to match your personal settings.

Performance Metrics

15.64s Prediction Time
15.68s Total Time
All Input Parameters
{
  "top_k": 50,
  "top_p": 0.8,
  "prompt": "Write a script to download the images for the top 10 posts of all time from /r/pics using the PRAW library",
  "temperature": 0.3,
  "max_new_tokens": 1024,
  "prompt_template": "<|im_start|>system\nYou are a helpful assistant<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n",
  "repetition_penalty": 1.2
}
Input Parameters
top_k Type: integerDefault: 50
The number of highest probability tokens to consider for generating the output. If > 0, only keep the top k tokens with highest probability (top-k filtering).
top_p Type: numberDefault: 0.8
A probability threshold for generating the output. If < 1.0, only keep the top tokens with cumulative probability >= top_p (nucleus filtering). Nucleus filtering is described in Holtzman et al. (http://arxiv.org/abs/1904.09751).
prompt (required) Type: string
temperature Type: numberDefault: 0.3
The value used to modulate the next token probabilities.
max_new_tokens Type: integerDefault: 1024
The maximum number of tokens the model should generate as output.
prompt_template Type: stringDefault: <|im_start|>system You are a helpful assistant<|im_end|> <|im_start|>user {prompt}<|im_end|> <|im_start|>assistant
The template used to format the prompt. The input prompt is inserted into the template using the `{prompt}` placeholder.
repetition_penalty Type: numberDefault: 1.2
Repetition penalty
Output Schema

Output

Type: arrayItems Type: string

Version Details
Version ID
14efadfaf772f45ee74c14973007cbafab3ccac90169ec96a9fc7a804253535d
Version Created
November 23, 2023
Run on Replicate →