From: microsoft <huggingface.co/microsoft>Newsgroups: alt.freeweights.phiSubject:

phi-1

Date: 2026-11-15Commit: d4c0adcSigned: 2DC28CC7B26A283B ✓

Text generation model with 1.4B parameters. Safetensors weights, 2.84 GB in all. Published by microsoft under MIT.

1.4B params2.84GBphi-1safetensorspermissive
FactsParams1.4BSize2.84 GBFormatssafetensorsTasktext generationLicenseMITFrom sourcepermissive
$ fw get microsoft/phi-1
# manifest sha256 eca885eedb93… · 2.84 GB · 16 files
$ fw verify ./phi-1 microsoft/phi-1
From sourceHosted (signed)microsoft/phi-1Last check: 2026-11-15 02:44 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Works with

Overview

Size
2.84 GB
Weights
2.84 GB (safetensors)
Parameters
1.4B
Formats
safetensors
Task
text generation
License
MIT (permissive)
Files
16, each with a sha256
Publisher
microsoft
Added
2026-11-15
Section
alt.freeweights.phi
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 02:44 UTCpassed

Model card

From the publisher at commit d4c0adc. Shown as plain text with links; images open at the publisher.

Model Summary#

The language model Phi-1 is a Transformer with 1.3 billion parameters, specialized for basic Python coding. Its training involved a variety of data sources, including subsets of Python codes from The Stack v1.2, Q&A content from StackOverflow, competition code from code_contests, and synthetic Python textbooks and exercises generated by gpt-3.5-turbo-0301. Even though the model and the datasets are relatively small compared to contemporary Large Language Models (LLMs), Phi-1 has demonstrated an impressive accuracy rate exceeding 50% on the simple Python coding benchmark, HumanEval.

How to Use#

Phi-1 has been integrated in the transformers version 4.37.0, please ensure that you are using a version equal or higher than it.

Intended Uses#

Given the nature of the training data, Phi-1 is best suited for prompts using the code format:

Code Format:#
def print_prime(n):
   """
   Print all primes between 1 and n
   """
   for num in range(2, n+1):
       for i in range(2, num):
           if num % i == 0:
               break
       else:
           print(num)

where the model generates the code after the comments. (Note: This is a legitimate and correct use of the else statement in Python loops.)

Notes:

  • Phi-1 is intended for code purposes. The model-generated code should be treated as a starting point rather than a definitive solution for potential use cases. Users should be cautious when employing this model in their applications.
  • Direct adoption for production coding tasks is out of the scope of this research project. As a result, Phi-1 has not been tested to ensure that it performs adequately for production-level code. Please refer to the limitation sections of this document for more details.

Sample Code#

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

torch.set_default_device("cuda")

model = AutoModelForCausalLM.from_pretrained("microsoft/phi-1", torch_dtype="auto")
tokenizer = AutoTokenizer.from_pretrained("microsoft/phi-1")

inputs = tokenizer('''def print_prime(n):
   """
   Print all primes between 1 and n
   """''', return_tensors="pt", return_attention_mask=False)

outputs = model.generate(**inputs, max_length=200)
text = tokenizer.batch_decode(outputs)[0]
print(text)

Limitations of Phi-1#

  • Limited Scope: 99.8% of the Python scripts in our fine-tuning dataset use only the packages "typing, math, random, collections, datetime, itertools". If the model generates Python scripts that utilize other packages, we strongly recommend users manually verify all API uses.
  • Replicate Scripts Online: As our model is trained on Python scripts found online, there is a small chance it may replicate such scripts, especially if they appear repetitively across different online sources.
  • Generate Inaccurate Code: The model frequently generates incorrect code. We suggest that users view these outputs as a source of inspiration rather than definitive solutions.
  • Unreliable Responses to Alternate Formats: Despite appearing to comprehend instructions in formats like Q&A or chat, our models often respond with inaccurate answers, even when seeming confident. Their capabilities with non-code formats are significantly more limited.
  • Limitations on Natural Language Comprehension. As a coding bot, Phi-1's main focus is to help with coding-related questions. While it may have some natural language comprehension capabilities, its primary function is not to engage in general conversations or demonstrate common sense like a general AI assistant. Its strength lies in providing assistance and guidance in the context of programming and software development.
  • Potential Biases: Phi-1, like other AI models, is trained on web and synthetic data. This data can contain biases and errors that might affect the AI's performance. Biases could stem from various sources like unbalanced representation, stereotypes, or controversial opinions present in the training data. As a result, the model might sometimes generate responses that reflect these biases or errors.

Warning about Security Risks#

When leveraging Phi-1, it's paramount to be vigilant. The model, though powerful, can inadvertently introduce security vulnerabilities in the generated code. Examples include, but are not limited to:

  • Directory Traversal: The code might fail to implement safe checks against directory traversal attacks, potentially allowing unauthorized access to sensitive files on your system.
  • Injection Attacks: There could be lapses in escaping strings properly, making the application susceptible to SQL, OS commands, or other injection attacks.
  • Misunderstanding Requirements: The model might sometimes misunderstand or oversimplify user requirements, leading to incomplete or insecure solutions.
  • Lack of Input Validation: In some cases, the model might neglect to incorporate input validation or sanitize user inputs, opening doors to attacks like Cross-Site Scripting (XSS).
  • Insecure Defaults: The model might recommend or generate code with insecure default settings, such as weak password requirements or unencrypted data transmissions.
  • Failure in Error Handling: Improper error handling can inadvertently reveal sensitive information about the system or the application's internal workings.

Given these potential pitfalls, and others not explicitly mentioned, it's essential to thoroughly review, test, and verify the generated code before deploying it in any application, especially those that are security-sensitive. Always consult with security experts or perform rigorous penetration testing when in doubt.

Training#

Model#
  • Architecture: a Transformer-based model with next-word prediction objective
  • Training tokens: 54B tokens (7B unique tokens)
  • Precision: fp16
  • GPUs: 8 A100
  • Training time: 6 days
Software#
License#

The model is licensed under the MIT license.

Citation#
@article{gunasekar2023textbooks,
  title={Textbooks Are All You Need},
  author={Gunasekar, Suriya and Zhang, Yi and Aneja, Jyoti and Mendes, Caio C{\'e}sar Teodoro and Del Giorno, Allie and Gopi, Sivakanth and Javaheripi, Mojan and Kauffmann, Piero and de Rosa, Gustavo and Saarikivi, Olli and others},
  journal={arXiv preprint arXiv:2306.11644},
  year={2023}
}

Trademarks#

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.

Data Summary#

https://huggingface.co/microsoft/phi-1/blob/main/data_summary_card.md

Files

16 files · 2.84 GBWeights 2.84 GB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 16 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
CODE_OF_CONDUCT.md444 B9daeae709a0bd71bcfd1c96dc5822ecec5210327eff929da64b0ae7f8faf1444
LICENSE1.08 KBfa8235e5b48faca34e3ca98cf4f694ef08bd216d28b58071a1f85b1d50cb814d
NOTICE.md1.77 KB6ac541192c253d21cd16a597ce69c515868e031db3f32f75d996b993b5aca216
README.md7.54 KB64d0f87543768cb08b3ae36bc17fd0aa73c21d1acda5a5ac76706a5f8b9e7798
SECURITY.md2.66 KB7b6976eec43edfa68b79a459dd089c56b7a395916dbf1a01bd11e6d86e12128f
added_tokens.json1.08 KBeca8e90d1be6af3afeb1a37f070f9492645c551a9fb2e1ce2a4a8b21f04ffc8b
config.json734 B6a6a640160005481d97389210b2134e24d0ef200c5637c70c364162376448f3b
data_summary_card.md3.99 KB54127d2839a297b9f51ec96442f0decb42b0d26510f243bcf831c72f6228df3a
generation_config.json74 Bff7c43946d3177ab1c63ea647c4a5055ba2e47a9e359dfd0fc87298399520e25
merges.txt456 KB1ce1664773c50f3e0cc8842619a93edc4624525b728b188a9e0be33b7726adc5
model.safetensors2.84 GB04edc8656c418161222bc706d4f3524ef628e61cbb473b6a2451683e2cd1d8b7
special_tokens_map.json99 B6f50ab5a5a509a1c309d6171f339b196a900dc9c99ad0408ff23bb615fdae7ad
tokenizer.json2.11 MB337da36be7a71a6e88aa9148967a7bc8736f4b47c7de8e19ba92b89e80734cfc
tokenizer_config.json237 B001d5ef96609ff1bc02c1b7edabf97d4617c450620cf8dfbbad97c27cd9b5cb6
vocab.json798 KB3ba3c3109ff33976c4bd966589c11ee14fcaa1f4c9e5e154c2ed7f99d80709e7
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
d4c0adcb06 pinned now2026-11-15 02:44 UTC16 files · 2.84 GB

Use it

$ fw get microsoft/phi-1
# manifest sha256 eca885eedb93… · 2.84 GB · 16 files
$ fw verify ./phi-1 microsoft/phi-1
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/microsoft/phi-1.json --dir ./phi-1 $ python3 fw.py verify ./phi-1 ./microsoft__phi-1.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download microsoft/phi-1 --revision d4c0adcb065e84e00ca814e35cba3012ea9841ab --local-dir ./phi-1
transformersLoad the weights in Python.
import os os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com" from transformers import AutoModelForCausalLM, AutoTokenizer tok = AutoTokenizer.from_pretrained("microsoft/phi-1", revision="d4c0adcb065e84e00ca814e35cba3012ea9841ab") model = AutoModelForCausalLM.from_pretrained("microsoft/phi-1", revision="d4c0adcb065e84e00ca814e35cba3012ea9841ab", device_map="auto")
vLLMServe an OpenAI-compatible API.
$ HF_ENDPOINT=https://freeweights.allternit.com vllm serve microsoft/phi-1 --revision d4c0adcb065e84e00ca814e35cba3012ea9841ab

License

Name
MIT License
Id
MIT
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
LICENSE
Text sha256
fa8235e5b48faca34e3ca98cf4f694ef08bd216d28b58071a1f85b1d50cb814d
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: microsoft <huggingface.co/microsoft>Newsgroups: alt.freeweights.phiSubject: phi-1Date: 2026-11-15Commit: d4c0adcSigned: 2DC28CC7B26A283B ✓
Upstream
microsoft/phi-1
Pinned commit
d4c0adcb065e84e00ca814e35cba3012ea9841ab
Manifest
phi-1.json · .minisig
Manifest sha256
eca885eedb937d0c3c9859633c298bdd289a9930c6d55f830177c888630f879c
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 02:44 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/microsoft/phi-1.json $ curl -O https://freeweights.allternit.com/manifests/microsoft/phi-1.json.minisig $ minisign -Vm phi-1.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

No related models in this catalog.Nothing here lists this model as its parent, and it names no parent.
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download microsoft/phi-1
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. phi-1.json. Provenance. Takedown history: none.
From: BAAI <huggingface.co/BAAI>Subject: bunny-phi-2-siglip-lora
From: microsoft <huggingface.co/microsoft>Subject: MediPhi
From: microsoft <huggingface.co/microsoft>Subject: MediPhi-Clinical
From: microsoft <huggingface.co/microsoft>Subject: MediPhi-Guidelines
From: microsoft <huggingface.co/microsoft>Subject: MediPhi-Instruct
From: microsoft <huggingface.co/microsoft>Subject: MediPhi-MedCode