#candle #pytorch #crf

candle-crf

porting pytorch-crf to candle

6 releases

0.8.4 Sep 19, 2024
0.8.3 Aug 17, 2024
0.7.3 Jul 18, 2024

#595 in Machine learning

Download history 193/week @ 2024-07-14 16/week @ 2024-07-21 5/week @ 2024-07-28 89/week @ 2024-08-04 296/week @ 2024-08-11 46/week @ 2024-08-18 2/week @ 2024-08-25 2/week @ 2024-09-01 78/week @ 2024-09-15 33/week @ 2024-09-22

114 downloads per month

Custom license

82KB
2K SLoC

Candle CRF

Candle CRF ports pytorch-crf to Huggingface Candle.

Initialization

  • Pytorch CRF

    crf = CRF(num_tags, batch_first=false)
    
  • Candle CRF

    let crf = CRF::new(num_tags, false, &candle_core::Device::Cpu).unwrap();
    

Forward

  • Pytorch CRF

    llh = crf(emissions, tags, mask)
    
  • Candle CRF

    let llh = crf
            .forward(&emissions, &tags, Some(&mask), Reduction::default())
            .unwrap();
    

Decode

  • Pytorch CRF

    best_tags = crf.decode(emissions, mask)
    
  • Candle CRF

    let best_tags = crf.decode(&emissions, Some(&mask)).unwrap();
    

Dependencies

~10–20MB
~328K SLoC