可以在不克隆仓库的情况下读取回购中的特定文件(通过代码)吗?

发布于 2025-02-03 02:05:03 字数 95 浏览 5 评论 0 原文

我有一个回购列表,我想阅读每个存储库中存在的一些特定文件(全部通过代码完成)。有没有我不必单独克隆每个存储库的方法,而只是读取回购文件中的信息?所有这些存储库都是公开的。谢谢您

I have a list of repo and I want to read some specific files present in each of the repo (all done through code). Is there way that I don't have to clone each repo individually at all but just read the info inside the file of the repo ? All these repos are public. Thank you in advanced

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柒七 2025-02-10 02:05:03
  1. 组合“原始”文件URL,看起来像: https://raw.githubusercontent.com/ {org/user}/{repo}/{branch}/{branch}/{file}/{file} ,示例:变为: https://raw.githubusercontent.com/openai/gpt-3/master/master/readme.md.md
  2. 然后,请使用curl fet ficth fine:
    curl {url} 。在这种情况下:
curl https://raw.githubusercontent.com/openai/gpt-3/master/README.md

输出:

# GPT-3: Language Models are Few-Shot Learners

[arXiv link](https://arxiv.org/abs/2005.14165)
> Recent work has demonstrated substantial gains on many NLP tasks and benchmarks by pre-training on a large corpus of text followed by fine-tuning on a specific task. While typically task-agnostic in architecture, this method still requires task-specific fine-tuning datasets of thousands or tens of thousands of examples. By contrast, humans can generally perform a new language task from only a few examples or from simple instructions – something which current NLP systems still largely struggle to do. Here we show that scaling up language models greatly improves task-agnostic, few-shot performance, sometimes even reaching competitiveness with prior state-of-the-art fine-tuning approaches. Specifically, we train GPT-3, an autoregressive language model with 175 billion parameters, 10x more than any previous non-sparse language model, and test its performance in the few-shot setting.  For all tasks, GPT-3 is applied without any gradient updates or fine-tuning, with tasks and few-shot demonstrations specified purely via text interaction with the model.  GPT-3 achieves strong performance on many NLP datasets, including translation, question-answering, and cloze tasks, as well as several tasks that require on-the-fly reasoning or domain adaptation, such as unscrambling words, using a novel word in a sentence, or performing 3-digit arithmetic. At the same time, we also identify some datasets where GPT-3's few-shot learning still struggles, as well as some datasets where GPT-3 faces methodological issues related to training on large web corpora. Finally, we find that GPT-3 can generate samples of news articles which human evaluators have difficulty distinguishing from articles written by humans.  We discuss broader societal impacts of this finding and of GPT-3 in general.

## Contents
- [175b_samples.jsonl](175b_samples.jsonl) - Unconditional, unfiltered 2048 token samples from GPT-3 with p=.85, t=1. 
**CONTENT WARNING:** GPT-3 was trained on arbitrary data from the web, so may contain offensive content and language.
- [data](data) - Synthetic datasets for word scramble and arithmetic tasks described in the paper.
- [dataset_statistics](dataset_statistics) - Statistics for all languages included in the training dataset mix.
- [overlap_frequency.md](overlap_frequency.md) - Samples of 13-gram overlaps between our training data and benchmarks, selected by frequency in the training set.
- [model-card.md](model-card.md) - GPT-3 Model Card.

## How to cite
`
@article{brown2020language,
    title={Language Models are Few-Shot Learners},
    author={Tom B. Brown and Benjamin Mann and Nick Ryder and Melanie Subbiah and Jared Kaplan and Prafulla Dhariwal and Arvind Neelakantan and Pranav Shyam and Girish Sastry and Amanda Askell and Sandhini Agarwal and Ariel Herbert-Voss and Gretchen Krueger and Tom Henighan and Rewon Child and Aditya Ramesh and Daniel M. Ziegler and Jeffrey Wu and Clemens Winter and Christopher Hesse and Mark Chen and Eric Sigler and Mateusz Litwin and Scott Gray and Benjamin Chess and Jack Clark and Christopher Berner and Sam McCandlish and Alec Radford and Ilya Sutskever and Dario Amodei},
    year={2020},
    eprint={2005.14165},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}
`
  1. Compose the "Raw" file URL, it will look something like: https://raw.githubusercontent.com/{org/user}/{repo}/{branch}/{file}, example: https://github.com/openai/gpt-3/blob/master/README.md becomes: https://raw.githubusercontent.com/openai/gpt-3/master/README.md
  2. Then, use cURL to fetch the file:
    curl {url}. In this case:
curl https://raw.githubusercontent.com/openai/gpt-3/master/README.md

Outputs:

# GPT-3: Language Models are Few-Shot Learners

[arXiv link](https://arxiv.org/abs/2005.14165)
> Recent work has demonstrated substantial gains on many NLP tasks and benchmarks by pre-training on a large corpus of text followed by fine-tuning on a specific task. While typically task-agnostic in architecture, this method still requires task-specific fine-tuning datasets of thousands or tens of thousands of examples. By contrast, humans can generally perform a new language task from only a few examples or from simple instructions – something which current NLP systems still largely struggle to do. Here we show that scaling up language models greatly improves task-agnostic, few-shot performance, sometimes even reaching competitiveness with prior state-of-the-art fine-tuning approaches. Specifically, we train GPT-3, an autoregressive language model with 175 billion parameters, 10x more than any previous non-sparse language model, and test its performance in the few-shot setting.  For all tasks, GPT-3 is applied without any gradient updates or fine-tuning, with tasks and few-shot demonstrations specified purely via text interaction with the model.  GPT-3 achieves strong performance on many NLP datasets, including translation, question-answering, and cloze tasks, as well as several tasks that require on-the-fly reasoning or domain adaptation, such as unscrambling words, using a novel word in a sentence, or performing 3-digit arithmetic. At the same time, we also identify some datasets where GPT-3's few-shot learning still struggles, as well as some datasets where GPT-3 faces methodological issues related to training on large web corpora. Finally, we find that GPT-3 can generate samples of news articles which human evaluators have difficulty distinguishing from articles written by humans.  We discuss broader societal impacts of this finding and of GPT-3 in general.

## Contents
- [175b_samples.jsonl](175b_samples.jsonl) - Unconditional, unfiltered 2048 token samples from GPT-3 with p=.85, t=1. 
**CONTENT WARNING:** GPT-3 was trained on arbitrary data from the web, so may contain offensive content and language.
- [data](data) - Synthetic datasets for word scramble and arithmetic tasks described in the paper.
- [dataset_statistics](dataset_statistics) - Statistics for all languages included in the training dataset mix.
- [overlap_frequency.md](overlap_frequency.md) - Samples of 13-gram overlaps between our training data and benchmarks, selected by frequency in the training set.
- [model-card.md](model-card.md) - GPT-3 Model Card.

## How to cite
`
@article{brown2020language,
    title={Language Models are Few-Shot Learners},
    author={Tom B. Brown and Benjamin Mann and Nick Ryder and Melanie Subbiah and Jared Kaplan and Prafulla Dhariwal and Arvind Neelakantan and Pranav Shyam and Girish Sastry and Amanda Askell and Sandhini Agarwal and Ariel Herbert-Voss and Gretchen Krueger and Tom Henighan and Rewon Child and Aditya Ramesh and Daniel M. Ziegler and Jeffrey Wu and Clemens Winter and Christopher Hesse and Mark Chen and Eric Sigler and Mateusz Litwin and Scott Gray and Benjamin Chess and Jack Clark and Christopher Berner and Sam McCandlish and Alec Radford and Ilya Sutskever and Dario Amodei},
    year={2020},
    eprint={2005.14165},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}
`
ぃ双果 2025-02-10 02:05:03
  1. 如果它是公共存储库,则答案是 Victor Maricato 直接。

  2. 如果私人存储库
    您可以在此处找到对此的参考: https://docs.github.com/en/rest/repos/contents?apiversion=2022-11-11-28#get-repository-content

但是,对于私人存储库,您将在base64中获得内容格式以获取简单的bash脚本以获取文件的内容,请使用以下方式:

    #!/bin/bash
    
    # Define variables
    REPO_OWNER="OWNER"  # Replace with the GitHub repository owner's username or organization name
    REPO_NAME="REPO_NAME"  # Replace with the GitHub repository name
    FILE_NAME="FILE_NAME"  # Replace with the name of the file you want to retrieve
    COMMIT_SHA="COMMIT_SHA"  # Replace with the SHA of the specific commit
    TOKEN="YOUR_TOKEN"  # Replace with your GitHub personal access token
    
    # Store the JSON response, including base64-encoded content, in a variable
    json_response=$(curl -L \
      -H "Accept: application/vnd.github+json" \
      -H "Authorization: Bearer $TOKEN" \
      -H "X-GitHub-Api-Version: 2022-11-28" \
      "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/contents/$FILE_NAME?ref=$COMMIT_SHA")
    
    # Extract the base64-encoded content from the JSON response, remove whitespace
    base64_encoded_content=$(echo "$json_response" | jq -r .content | tr -d '[:space:]')
    
    # Decode the content and save it to a file
    echo "$base64_encoded_content" | base64 -d > "$FILE_NAME"
  1. In case it is a public repository, the answer by Victor Maricato is simple and straightforward.

  2. In case of a private repository:
    You can find reference to this here: https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content

However, for a private repository you will get the content in base64 format so to get a simple bash script to get the contents of the file use this:

    #!/bin/bash
    
    # Define variables
    REPO_OWNER="OWNER"  # Replace with the GitHub repository owner's username or organization name
    REPO_NAME="REPO_NAME"  # Replace with the GitHub repository name
    FILE_NAME="FILE_NAME"  # Replace with the name of the file you want to retrieve
    COMMIT_SHA="COMMIT_SHA"  # Replace with the SHA of the specific commit
    TOKEN="YOUR_TOKEN"  # Replace with your GitHub personal access token
    
    # Store the JSON response, including base64-encoded content, in a variable
    json_response=$(curl -L \
      -H "Accept: application/vnd.github+json" \
      -H "Authorization: Bearer $TOKEN" \
      -H "X-GitHub-Api-Version: 2022-11-28" \
      "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/contents/$FILE_NAME?ref=$COMMIT_SHA")
    
    # Extract the base64-encoded content from the JSON response, remove whitespace
    base64_encoded_content=$(echo "$json_response" | jq -r .content | tr -d '[:space:]')
    
    # Decode the content and save it to a file
    echo "$base64_encoded_content" | base64 -d > "$FILE_NAME"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文