resp = client.chat.completions.create( model="bitnet1b", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain Neural Networks in simple terms."} ], temperature=0.7, max_tokens=200, )
print(resp.choices[0].message.content)
代码说明:
base_url:指向你的本地BitNet服务器;
api_key:SDK要求必须提供,但通常被本地服务器忽略;
model:应与服务器暴露的模型名称匹配;
messages:定义系统提示词和用户提示词。
输出结果:
Neural networks are a type of machine learning model inspired by the human brain. They are used to recognize patterns in data. Think of them as a group of neurons (like tiny brain cells) that work together to solve a problem or make a prediction.
Imagine you are trying to recognize whether a picture shows a cat or a dog. A neural network would take the picture as input and process it. Each neuron in the network would analyze a small part of the picture, like a whisker or a tail. They would then pass this information to other neurons, which would analyze the whole picture.
By sharing and combining the information, the network can make a decision about whether the picture shows a cat or a dog.
In summary, neural networks are a way for computers to learn from data by mimicking how our brains work. They can recognize patterns and make decisions based on that recognition.