我正在尝试加载量化
from transformers import LlamaForCausalLM
from transformers import BitsAndBytesConfig
model = '/model/'
model = LlamaForCausalLM.from_pretrained(model, quantization_config=BitsAndBytesConfig(load_in_8bit=True))
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
ImportError: Using `load_in_8bit=True` requires Accelerate: `pip install accelerate` and the latest version of bitsandbytes `pip install -i https://test.pypi.org/simple/ bitsandbytes` or pip install bitsandbytes`
Run Code Online (Sandbox Code Playgroud)
但我都安装了,但出现同样的错误。我关闭并重新启动了我正在使用的 jupyter 内核。
语境
我正在尝试对 XGBoost 二元分类器使用自定义损失函数。
这个想法是在 XGBoost 中实现 soft-Fbeta 损失,我在这里读到了这一点。简单地说:不使用标准的对数损失,而是使用直接优化 Fbeta 分数的损失函数。
警告
当然,Fbeta 本身是不可微分的,因此不能直接开箱即用。然而,我们的想法是使用概率(因此,在阈值化之前)来创建某种连续的 TP、FP 和 FN。在参考的 Medium 文章中查找更多详细信息。
试图
我的尝试如下(受到几个不同人的启发)。
import numpy as np
import xgboost as xgb
def gradient(y: np.array, p: np.array, beta: float):
"""Compute the gradient of the loss function. y is the true label, p
the probability predicted by the model """
# Define the denominator
D = p.sum() + beta**2 * y.sum()
# Compute the gradient
grad = (1 + beta**2) * y …Run Code Online (Sandbox Code Playgroud) class Hero(SQLModel, table=True):
id: int = Field(primary_key=True)
name: str
age: int = Field(default=None)
status:str
Run Code Online (Sandbox Code Playgroud)
我使用 创建表SQLModel.metadata.create_all(engine),当我将状态类型更改为str并再次运行该create_all()方法时,数据库中的状态类型没有更改。有没有像Django或flask-migrate那样迁移数据库的方法?
最近,我为 CodeIgniter 下载了Phil Strugeon REST 服务器。\n我查看了源代码,当我进行摘要式身份验证时,我看到了以下代码:
\nif ($this->input->server(\'PHP_AUTH_DIGEST\'))\n{\n $digest_string = $this->input->server(\'PHP_AUTH_DIGEST\');\n}\nelseif ($this->input->server(\'HTTP_AUTHORIZATION\'))\n{\n $digest_string = $this->input->server(\'HTTP_AUTHORIZATION\');\n}\nelse\n{\n $digest_string = "";\n}\n \nRun Code Online (Sandbox Code Playgroud)\n稍后检查是否存在 $digest_string 和用户名:
\n// This is the valid response expected\n$A1 = md5($digest[\'username\'].\':\'.$this->config->item(\'rest_realm\').\':\'.$valid_pass);\n$A2 = md5(strtoupper($this->request->method).\':\'.$digest[\'uri\']);\n$valid_response = md5($A1.\':\'.$digest[\'nonce\'].\':\'.$digest[\'nc\'].\':\'.$digest[\'cnonce\'].\':\'.$digest[\'qop\'].\':\'.$A2);\n\nif ($digest[\'response\'] != $valid_response)\n{\n header(\'HTTP/1.0 401 Unauthorized\');\n header(\'HTTP/1.1 401 Unauthorized\');\n exit;\n}\n \nRun Code Online (Sandbox Code Playgroud)\n在Wikipedia中,我看到以下有关 HTTP Digest Auth 的文本:
\n\n\n对于后续请求,十六进制请求计数器 (nc) 必须大于它使用的最后一个值 \xe2\x80\x93,否则攻击者可以简单地使用相同的凭据“重放”旧请求。服务器负责确保计数器针对其发出的每个随机数值而增加,从而适当地拒绝任何错误请求。
\n服务器应该记住它最近生成的随机数值。它还可以记住每个随机数值的发布时间,并在一定时间后使其过期。如果使用过期值,服务器应使用“401”状态代码进行响应,并将 stale=TRUE 添加到身份验证标头,指示客户端应使用提供的新随机数重新发送,而不提示用户输入另一个用户名和密码。
\n
但是,我在源代码中看不到任何有关检查 cnonce、nc 或 nonce 的信息。\n这是否意味着从客户端记录请求到通过身份验证的服务器的人可能会在将来“重放”它并接收新的资源值?
\n真的是脆弱吗?或者我误解了什么?
\n我有一个 protobuf 文件如下:
message Lesson {
int64 UserId = 1;
int32 CourseId = 2;
int32 LessonId = 3;
LessonStatus Status = 4;
google.protobuf.Timestamp DateSubmitted = 5;
message Question {
string QuestionId = 1;
string StudentAnswer = 2;
QuestionStatus Status = 3;
string SupComment = 4;
}
repeated Question Questions = 6;
}
Run Code Online (Sandbox Code Playgroud)
}
protobuf 文件导入为api.
使用 来创建单个对象Lesson_Question很简单&api.Lesson_Question{},但我正在尝试创建一部分问题。我已经用谷歌搜索了一段时间,没有找到任何关于此的文档。
我尝试过各种组合,例如:
questions := []*api.Lesson_Questionquestions := []&api.Lesson_Questionquestions := &[]api.Lesson_Questionquestions := *[]api.Lesson_Questionquestions := []api.Lesson_Question但都给出错误。 …