Feature Extraction
Transformers
PyTorch
roberta
code-understanding
unixcoder
text-embeddings-inference
Run this model with HF Jobs
Run Henry65/RepoSim4Py on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Henry65/RepoSim4Py. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Henry65/RepoSim4Py on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Henry65/RepoSim4Py with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Henry65/RepoSim4Py with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Henry65/RepoSim4Py")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("Henry65/RepoSim4Py") model = AutoModel.from_pretrained("Henry65/RepoSim4Py", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update RepoPipeline.py
Browse files125 unmodified lines1261271281291301311321336 unmodified lines140141142143144145146147142 unmodified lines2902912922932942952962972982993003013023033043053063073083093103113123133141 unmodified line316317318319320321322323324325326327328125 unmodified lines)except SyntaxError as e:tqdm.write(f"[-] SyntaxError in {member.name}, skipping: \n{e}")elif (member.name.endswith("README.md") or member.name.endswith("README.rst")) and member.isfile():# 3. Extracting readme.try:file_content = tar.extractfile(member).read().decode("utf-8")# extract readme6 unmodified lines)except SyntaxError as e:tqdm.write(f"[-] SyntaxError in {member.name}, skipping: \n{e}")elif member.name.endswith("requirements.txt") and member.isfile():# 4. Extracting requirements.try:lines = tar.extractfile(member).readlines().decode("utf-8")# extract readme142 unmodified linestqdm.write(f"[*] Generating code embeddings for {repo_name}")code_embeddings = self.generate_embeddings(repo_info["codes"], max_length)info["code_embeddings"] = code_embeddings.cpu().numpy()info["mean_code_embedding"] = torch.mean(code_embeddings, dim=0).cpu().numpy()# Doc embeddingstqdm.write(f"[*] Generating doc embeddings for {repo_name}")doc_embeddings = self.generate_embeddings(repo_info["docs"], max_length)info["doc_embeddings"] = doc_embeddings.cpu().numpy()info["mean_doc_embedding"] = torch.mean(doc_embeddings, dim=0).cpu().numpy()# Requirement embeddingstqdm.write(f"[*] Generating requirement embeddings for {repo_name}")requirement_embeddings = self.generate_embeddings(repo_info["requirements"], max_length)info["requirement_embeddings"] = requirement_embeddings.cpu().numpy()info["mean_requirement_embedding"] = torch.mean(requirement_embeddings, dim=0).cpu().numpy()# Readme embeddingstqdm.write(f"[*] Generating readme embeddings for {repo_name}")readme_embeddings = self.generate_embeddings(repo_info["readmes"], max_length)info["readme_embeddings"] = readme_embeddings.cpu().numpy()info["mean_readme_embedding"] = torch.mean(readme_embeddings, dim=0).cpu().numpy()# Repo-level mean embeddinginfo["mean_repo_embedding"] = np.concatenate([1 unmodified lineinfo["mean_doc_embedding"],info["mean_requirement_embedding"],info["mean_readme_embedding"]], axis=0)# TODO Remove testinfo["code_embeddings_shape"] = info["code_embeddings"].shapeinfo["doc_embeddings_shape"] = info["doc_embeddings"].shapeinfo["requirement_embeddings_shape"] = info["requirement_embeddings"].shapeinfo["readme_embeddings_shape"] = info["readme_embeddings"].shapeinfo["mean_repo_embedding_shape"] = info["mean_repo_embedding"].shapeprogress_bar.update(1)125 unmodified lines1261271281291301311321336 unmodified lines140141142143144145146147142 unmodified lines2902912922932942952962972982993003013023033043053063073083093103113123133143151 unmodified line317318319320321322323324325326327328329330331332125 unmodified lines)except SyntaxError as e:tqdm.write(f"[-] SyntaxError in {member.name}, skipping: \n{e}")# 3. Extracting readme.elif (member.name.endswith("README.md") or member.name.endswith("README.rst")) and member.isfile():try:file_content = tar.extractfile(member).read().decode("utf-8")# extract readme6 unmodified lines)except SyntaxError as e:tqdm.write(f"[-] SyntaxError in {member.name}, skipping: \n{e}")# 4. Extracting requirements.elif member.name.endswith("requirements.txt") and member.isfile():try:lines = tar.extractfile(member).readlines().decode("utf-8")# extract readme142 unmodified linestqdm.write(f"[*] Generating code embeddings for {repo_name}")code_embeddings = self.generate_embeddings(repo_info["codes"], max_length)info["code_embeddings"] = code_embeddings.cpu().numpy()info["mean_code_embedding"] = torch.mean(code_embeddings, dim=0, keepdim=True).cpu().numpy()# Doc embeddingstqdm.write(f"[*] Generating doc embeddings for {repo_name}")doc_embeddings = self.generate_embeddings(repo_info["docs"], max_length)info["doc_embeddings"] = doc_embeddings.cpu().numpy()info["mean_doc_embedding"] = torch.mean(doc_embeddings, dim=0, keepdim=True).cpu().numpy()# Requirement embeddingstqdm.write(f"[*] Generating requirement embeddings for {repo_name}")requirement_embeddings = self.generate_embeddings(repo_info["requirements"], max_length)info["requirement_embeddings"] = requirement_embeddings.cpu().numpy()info["mean_requirement_embedding"] = torch.mean(requirement_embeddings, dim=0,keepdim=True).cpu().numpy()# Readme embeddingstqdm.write(f"[*] Generating readme embeddings for {repo_name}")readme_embeddings = self.generate_embeddings(repo_info["readmes"], max_length)info["readme_embeddings"] = readme_embeddings.cpu().numpy()info["mean_readme_embedding"] = torch.mean(readme_embeddings, dim=0, keepdim=True).cpu().numpy()# Repo-level mean embeddinginfo["mean_repo_embedding"] = np.concatenate([1 unmodified lineinfo["mean_doc_embedding"],info["mean_requirement_embedding"],info["mean_readme_embedding"]], axis=0).reshape(1, -1)info["code_embeddings_shape"] = info["code_embeddings"].shapeinfo["mean_code_embedding_shape"] = info["mean_code_embedding"].shapeinfo["doc_embeddings_shape"] = info["doc_embeddings"].shapeinfo["mean_doc_embedding_shape"] = info["mean_doc_embedding"].shapeinfo["requirement_embeddings_shape"] = info["requirement_embeddings"].shapeinfo["mean_requirement_embedding_shape"] = info["mean_requirement_embedding"].shapeinfo["readme_embeddings_shape"] = info["readme_embeddings"].shapeinfo["mean_readme_embedding_shape"] = info["mean_readme_embedding"].shapeinfo["mean_repo_embedding_shape"] = info["mean_repo_embedding"].shapeprogress_bar.update(1)
RepoPipeline.py+12-8