You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[0] to flatten the array, the output should be normalized to 1 during the unit test below, but its not
use function Codewithkyrian\Transformers\Pipelines\pipeline;
public function vectorize(string $text): array
{
return $this->extractor()($text, normalize: true, pooling: 'mean')[0];
}
Reproduction
run this unit test after implementing the vecotrize function in a class
public function test_vector_is_normalized(): void
{
$vector = self::$vectorizer->vectorize('normal unit test');
$norm = sqrt(array_sum(array_map(fn ($x) => $x ** 2, $vector)));
$this->assertEqualsWithDelta(1.0, $norm, 0.001);
}
Activity