Starter Brains · AI & Data

AI, ML & Data Engineering

20 lessons from merged PRs in Hugging Face Transformers, DuckDB and pandas, summarized in our own words. Fixes for ML pipelines and analytical SQL.

20 PR lessonshuggingface/transformers · Apache-2.0 (5)duckdb/duckdb · MIT (8)pandas-dev/pandas · BSD-3-Clause (7)
brain_seed_starter(instance_id="<your-brain-id>", stack="ai-data")

20 fixes from merged PRs

Every lesson below is a short summary in our own words and links to its upstream GitHub pull request in a permissive-licensed repository. Seed them into your Brain so your coding agent can find them when a similar problem comes up.

  1. transformers:pr-36859Apache-2.0huggingface/transformers#36859 ↗
    Symptom

    Gemma3ForConditionalGeneration in transformers uses 1-indexed position ids while the reference implementation uses 0-indexed ones.

    Cause and fix

    Cause: The modular Gemma3 class inherited from the PaliGemma class, carrying over a position-id adjustment that is specific to PaliGemma input ordering. Fix: The inherited adjustment was removed from the Gemma3 conditional-generation code in modular_gemma3.py and the generated modeling_gemma3.py.

  2. transformers:pr-35679Apache-2.0huggingface/transformers#35679 ↗
    Symptom

    Creating GenerationConfig(cache_implementation="static") in transformers is rejected unless a full cache config is supplied too.

    Cause and fix

    Cause: Static cache setup required extra cache parameters up front, although generate() can infer them at inference time. Fix: The validation in generation/configuration_utils.py was changed so a static cache_implementation alone is accepted.

  3. transformers:pr-40320Apache-2.0huggingface/transformers#40320 ↗
    Symptom

    A user-set YaRN factor in a transformers rope config is ignored when original_max_position_embeddings is also present.

    Cause and fix

    Cause: The factor derived implicitly from the position-embedding values took priority over the explicit factor. Fix: modeling_rope_utils.py now gives the explicit factor precedence and emits warnings when the YaRN parameters are missing or inconsistent.

  4. transformers:pr-43513Apache-2.0huggingface/transformers#43513 ↗
    Symptom

    The cardinality error logged during training of Deformable DETR, Grounding DINO, RT-DETR and similar models is wrong.

    Cause and fix

    Cause: These models use sigmoid or focal loss without a background class, so the argmax-against-last-class check from original DETR has no meaning for them. Fix: Their cardinality calculation now counts a query as an object when the maximum sigmoid score exceeds 0.5; the original DETR loss keeps its softmax logic.

  5. transformers:pr-46406Apache-2.0huggingface/transformers#46406 ↗
    Symptom

    Loading facebook/sam3 with Sam3Model in transformers 5.10.1 leaves the text encoder weights unloaded and randomly initialized, reported as both missing and unexpected.

    Cause and fix

    Cause: The key conversion was registered by model type, which other models share, rather than for the specific CLIP text class that Sam3 loads and used to unwrap manually. Fix: The mapping in conversion_mapping.py is now keyed by class name, so the conversion applies only to the model class that needs it.

  6. duckdb:pr-20910MITduckdb/duckdb#20910 ↗
    Symptom

    The error position in the JSON from errors_as_json via json_execute_serialized_sql() always points to the same wrong character instead of the failing spot.

    Cause and fix

    Cause: Binding a table macro caught the exception and unconditionally re-attached the macro reference's query location, overwriting a position already stored in the error. Fix: In BoundStatementBinder::Bind for TableFunctionRef, AddQueryLocation is now called only if the error has no position yet.

  7. duckdb:pr-17302MITduckdb/duckdb#17302 ↗
    Symptom

    In DuckDB, casting a float or double to a decimal rounds differently from PostgreSQL and loses precision, e.g. 1.45 to decimal(3,1).

    Cause and fix

    Cause: These casts used statistical (round-half-even) rounding. Fix: The cast operators in cast_operators.cpp now use half-up rounding for float and double to decimal conversion.

  8. duckdb:pr-22177MITduckdb/duckdb#22177 ↗
    Symptom

    read_parquet with union_by_name=true fails in DuckDB 1.5.1 when some files store an optional nested column as a plain NULL-like scalar type instead of a STRUCT.

    Cause and fix

    Cause: ConstructMapExpression sent non-nested local columns through remap_struct, which accepts only nested sources. Fix: Non-nested local columns are now handled by the ordinary cast path, so NULL-like columns stay readable while real scalar-versus-struct conflicts still give a cast error.

  9. duckdb:pr-15615MITduckdb/duckdb#15615 ↗
    Symptom

    Reading several JSON files whose keys differ only by letter case in DuckDB fails with a duplicate column name error such as Image_1.

    Cause and fix

    Cause: The suffix added to make colliding names unique could itself collide with a name that already existed. Fix: read_json.cpp now checks the suffixed name against existing columns when resolving collisions; nested JSON with the same issue is still not covered.

  10. duckdb:pr-17259MITduckdb/duckdb#17259 ↗
    Symptom

    A DuckDB query with ROLLUP or CUBE style grouping sets returns wrong results when the duplicate groups optimizer is on.

    Cause and fix

    Cause: Removing unused group-by columns while several grouping sets exist let the duplicate groups optimizer drop groups generated by rollup and cube. Fix: remove_unused_columns.cpp no longer removes unused group columns when there is more than one grouping set.

  11. duckdb:pr-20706MITduckdb/duckdb#20706 ↗
    Symptom

    DuckDB refuses to implicitly or explicitly cast a custom aliased type to a UNION that contains it as a member.

    Cause and fix

    Cause: The cast rules rejected any type with a mismatching alias before considering union members. Fix: union_casts.cpp and cast_rules.cpp now try casting the source to a member of the target union when the existing member-to-member route fails, keeping member-to-member casts first.

  12. duckdb:pr-22646MITduckdb/duckdb#22646 ↗
    Symptom

    After CALL truncate_duckdb_logs() on a CSV log file in DuckDB, the file shows a blank line before the header or has no header at all after a restart.

    Cause and fix

    Cause: Truncating the on-disk file left the CSV writer state and the header dialect option untouched, so the header was written wrongly or skipped in append mode. Fix: Truncation now resets the CSVWriter state and the CSV header option after cutting the file to zero length, before calling Initialize(true).

  13. duckdb:pr-23947MITduckdb/duckdb#23947 ↗
    Symptom

    A DuckDB select-list expression combining an equality test with an OR over two null checks returns false instead of NULL for rows where only one column is NULL.

    Cause and fix

    Cause: The EqualOrNullSimplification optimizer rule rewrites the pattern into IS NOT DISTINCT FROM, which is only valid for predicates; in projections it turns NULL into false. Fix: Limited the rewrite in equal_or_null_simplification.cpp to root filter and join predicates, leaving projection expressions unchanged, and added an optimizer test.

  14. pandas:pr-64605BSD-3-Clausepandas-dev/pandas#64605 ↗
    Symptom

    Indexing with a Categorical built from Interval values in pandas is very slow.

    Cause and fix

    Cause: Hashing the categories turned the IntervalIndex into an object array, which then fell back to string conversion in hash_object_array. Fix: CategoricalDtype._hash_categories now passes the extension array itself to hash_array, and IntervalArray gains a _hash_pandas_object that hashes left, right and closed directly.

  15. pandas:pr-64678BSD-3-Clausepandas-dev/pandas#64678 ↗
    Symptom

    In pandas, assigning with loc to a new key silently changes the dtype of the Series or DataFrame, for example int to float or extension dtype to object.

    Cause and fix

    Cause: Expansion paths disagree on dtype handling: some use concat-like casting, so adding a row can change dtype without notice. Fix: The PR adds a deprecation warning, raised from infer_and_maybe_downcast via _post_expansion_casting, saying dtype will be kept in future, while int-to-float promotion for NaN stays allowed.

  16. pandas:pr-65042BSD-3-Clausepandas-dev/pandas#65042 ↗
    Symptom

    Creating a pandas Categorical with a huge number of categories is slow because an is_unique check runs repeatedly.

    Cause and fix

    Cause: Construction went through CategoricalDtype.update_dtype, which revalidated categories that were already validated. Fix: _simple_new and __init__ now check ordered directly and use _from_fastpath, and update_dtype also uses _from_fastpath to skip repeated uniqueness and NA checks.

  17. pandas:pr-61594BSD-3-Clausepandas-dev/pandas#61594 ↗
    Symptom

    pandas CI jobs time out because the micromamba solver spends about 25 minutes resolving environments.

    Cause and fix

    Cause: boto3 publishes nearly daily, and the huge number of candidate versions slows the solver. Fix: The CI dependency files got a lower version bound of 1.27 on boto3, limiting how many versions the solver must consider.

  18. pandas:pr-61871BSD-3-Clausepandas-dev/pandas#61871 ↗
    Symptom

    DataFrame.describe(include=['datetime']) on a frame without datetime columns raises the unhelpful error 'No objects to concatenate'.

    Cause and fix

    Cause: The per-dtype describe results were concatenated even when the requested dtype matched no columns, leaving nothing to join. Fix: describe.py now raises a ValueError stating that no columns match the given include or exclude dtypes.

  19. pandas:pr-65470BSD-3-Clausepandas-dev/pandas#65470 ↗
    Symptom

    Reading compressed CSV through fsspec fails with 'ValueError: seek of closed file' on a Tar filesystem after upgrading to fsspec 2026.4.

    Cause and fix

    Cause: pandas.io.common._get_filepath_or_buffer called fsspec.open(...).open() and discarded the OpenFile object, which fsspec requires to stay alive while the handle is used. Fix: The function now keeps the OpenFile alive for as long as the returned file handle is in use, so the temporary fsspec upper pin can be removed.

  20. pandas:pr-61340BSD-3-Clausepandas-dev/pandas#61340 ↗
    Symptom

    pandas bar plots with stacked=True and subplots=True stack values differently than expected.

    Cause and fix

    Cause: Combining stacked with subplots computed offsets incorrectly, especially when columns did not all have values at the same positions. Fix: The plotting code now checks for stacked plus subplots in bar plots and computes offsets per subplot.

Explain it once. Every AI knows it. By default, no generative AI model reads or rewrites your lessons. A small ranking model in the EU only scores them. Starter lessons never overwrite your team's own project lessons.